Skip to content

Fix Background Jobs in *nix and Windows - #1972

Merged
Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:masterfrom
nanalakshmanan:JobFixes
Nov 10, 2016
Merged

Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:masterfrom
nanalakshmanan:JobFixes

Conversation

@nanalakshmanan

Copy link
Copy Markdown
Contributor

Resolve issue #452

@msftclas

Hi Nana Lakshmanan (@nanalakshmanan), I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!


It looks like you're a Microsoft contributor (Narayanan Lakshmanan). If you're full-time, we DON'T require a Contribution License Agreement. If you are a vendor, please DO sign the electronic Contribution License Agreement. It will take 2 minutes and there's no faxing! https://cla.microsoft.com.

TTYL, MSBOT;


#if CORECLR
processArguments = " -s -NoLogo -NoProfile";
#endif

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

          processArguments = string.Format(CultureInfo.InvariantCulture,  
                   "{0} -s -NoLogo -NoProfile", processArguments);  
#if CORECLR  
          processArguments = " -s -NoLogo -NoProfile";  
#endif

it's better to not have unused code in CoreCLR build. Can you please make it like the following?

#if CORECLR  
           string processArguments = " -s -NoLogo -NoProfile";
#elif
           // Adding Version parameter to powershell.exe 
           // Version parameter needs to go before all other parameters because the native layer looks for Version or  
           // PSConsoleFile parameters before parsing other parameters. 
           // The other parameters get parsed in the managed layer. 
           Version tempVersion = powerShellVersion ?? PSVersionInfo.PSVersion; 
           string processArguments = string.Format(CultureInfo.InvariantCulture, 
                      "-Version {0}", new Version(tempVersion.Major, tempVersion.Minor)); 

           processArguments = string.Format(CultureInfo.InvariantCulture,  
                      "{0} -s -NoLogo -NoProfile", processArguments);  
#endif   

@daxian-dbw Dongbo Wang (daxian-dbw) added the WG-Engine core PowerShell engine, interpreter, and runtime label Aug 19, 2016
@daxian-dbw

Copy link
Copy Markdown
Member

Fixing background jobs for Unix and Windows

The first commit seems using a different user email when it was committed. Can you please double check?

@TravisEz13

Copy link
Copy Markdown
Member

Still waiting on an answer to this question

@ffeldhaus

Copy link
Copy Markdown
Contributor

As Start-Job is one of the more important Cmdlets, it would be great if we could get this merged as soon as possible. Nana Lakshmanan (@nanalakshmanan) can [comment on the question above?](daxian-dbw commented 27 days ago)

It 'Job output test' {
Receive-Job $job -wait | should be 1
}
} No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a policy about missing EOL at EOF?

Personally, as someone who uses hg and git (and Linux), missing EOL markers at EOF result in lots of pain which I'd rather avoid.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen a strong argument for requiring EOL at EOF, and it comes up often enough to be somewhat annoying and distracting.

If it's truly a problem for some tools, I think we should just run a tool over our source from time to time and fix it instead of asking each contributor every time we see it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure where to start.

The length of a file "" and the length of a file "\n" aren't the same.
Version control systems at some point rely on hashing content and ensuring that they're reproducible.

diff and patch work on lines (things that end in "\n"). A patch generated for a properly ended line doesn't apply well to an improperly ended line and vice versa. This makes it hard to graft and merge changes.

Other things like wc (word count tool which also does line count) can be implemented by counting \ns, a file "hello\n" can be defined to have 1 line because it has 1 \n.

Many text editors as a courtesy to other tools (like diff and vcs and ...) will automatically insert the EOL at EOF.

There's a general goal in VCS for commits to have descriptions that describe the entirety of their changes, and for blame to be assignable based on the last user to change a given line.

These factors result in a file like:
"hello.....\n......\nworld" which was created by one person but, where I change "hello" to "Hello" with a message of "capitalizing Hello" also resulting in my commit often changing the file to:
"Hello.....\n......\nworld\n"

And when someone uses a tool to quickly view the blame for lines of the file, they'll think that I was responsible for "world\n".

If you've ever had problems trying to apply changes where a patch was \r\n and a file was \n, or where a file had mixed line endings, the missing EOL at EOF triggers roughly similar failures.

Trying to apply a change that's missing a line ending to a line that has a line ending:

$ cat c; d -c 4; d -c 4|patch c
Hello
world
a
diff --git a/c b/c
--- a/c
+++ b/c
@@ -1,3 +1,3 @@
 Hello
 world
-a
\ No newline at end of file
+b
\ No newline at end of file
patching file c
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file c.rej

Trying to apply a change with a line ending to a line that is missing a line ending:

 (cat c; echo XXX); d -r 1 -r 2; d -r 1 -r 2|patch c
Hello
world
aXXX
diff --git a/c b/c
--- a/c
+++ b/c
@@ -1,3 +1,3 @@
 Hello
 world
-a
+b
patching file c
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file c.rej

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converting the repository to not be missing line endings would be appreciated.
But I would still encourage you to also discourage people from adding files that are missing EOL at EOF because unless your script automatically commits the line changes as the user who added the line, you'll be distorting authorship for those lines.

@mirichmo

Copy link
Copy Markdown
Member

This is dependent on #2472

@daxian-dbw

Copy link
Copy Markdown
Member

Nana Lakshmanan (@nanalakshmanan) The PR #2472 has been merged, and now powershell is building against the latest preview .NET Core bits.
Can you please update your changes accordingly?

@vors

Copy link
Copy Markdown
Collaborator

Nana Lakshmanan (@nanalakshmanan) can you, please, update the PR and resolve conflicts?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be else?

Comment thread test/powershell/engine/Jobs.Tests.ps1 Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should be in a BeforeAll block.

Also, I think the job should be removed in a AfterAll block.

Comment thread test/powershell/engine/Jobs.Tests.ps1 Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 seconds might not be enough time to wait on a heavily loaded system, especially with debug binaries that aren't pre-jit compiled.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a good timeout that you suggest?

It 'Job output test' {
Receive-Job $job -wait | should be 1
}
} No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen a strong argument for requiring EOL at EOF, and it comes up often enough to be somewhat annoying and distracting.

If it's truly a problem for some tools, I think we should just run a tool over our source from time to time and fix it instead of asking each contributor every time we see it.

@daxian-dbw

Copy link
Copy Markdown
Member

Nana Lakshmanan (@nanalakshmanan) Github cannot recognize your account.
image
This is usually because the email account of your local clone is different from your email address of Github account. Can you please fix it?

@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit 2077e42 into PowerShell:master Nov 10, 2016
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WG-Engine core PowerShell engine, interpreter, and runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants