You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Redirection of stderr output from external programs sets $? invariably to $false, no longer reflecting whether $LASTEXITCODE equals 0 #10512
Normally, immediately after execution of an external program, $? and $LASTEXITCODE -eq 0 can be used interchangeably to test for success.
However, under the following conditions $? is invariably set to $false, even if $LASTEXITCODE contains 0 and therefore indicates success:
If a 2> or *> redirection is involved
and actual stderr output is produced by the external program.
Note that you generally cannot and shouldn't infer success vs. failure of an external program from the presence of stderr output - many CLIs use stderr to emit status information; only the process exit code should be consulted.
Steps to reproduce
Run the following on Windows, which produces both stderr and stdout output and reports 0 as the process exit code:
Activity
mklement0 commentedon Aug 2, 2020
Closed in favor of #3996 (comment)