-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Closed
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.Resolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or more
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
The pre-v7.3 experimental PSNativeCommandErrorActionPreference feature allows setting the new $PSNativeCommandUseErrorActionPreference preference variable to $true, so that any call to an external (native) program that results in a nonzero exit code emits a PowerShell error (in addition to any preceding stderr output emitted by the external program itself).
For this error to be most useful, it should be a statement-terminating error - i.e. one that can be caught with try / catch, whereas it currently is a non-terminating error.
Note that the concept of a non-terminating error is a PowerShell-specific one, and doesn't really apply to external programs.
$PSNativeCommandUseErrorActionPreference = $true
try {
# Call an external program that reports a nonzero exit code.
& ($IsWindows ? 'cmd' : 'sh') ($IsWindows ? '/c' : '-c') 'exit 1'
}
catch {
'caught!'
}
'after'Expected behavior
caught!
afterActual behavior
NativeCommandExitException: Program "sh" ended with non-zero exit code: 1.
afterThat is, the unexpectedly non-terminating error wasn't caught.
Error details
No response
Environment data
PowerShell Core 7.3.0-preview.8Visuals
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.Resolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or more