PowerShell: NativeCommandExitException should display "negative" exit codes in hex, not decimal
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
When a native command exits with a “negative” (high-order bit set) exit code, PowerShell 7.4.0-preview.4 displays something like:
NativeCommandExitException: Program "winget.exe" ended with non-zero exit code: -1978335212.
This negative value cannot (really) be made sense of unless you convert it to hex (0x8a150014
in that case).
Expected behavior
NativeCommandExitException: Program "winget.exe" ended with non-zero exit code: 0x8a150014.
Actual behavior
NativeCommandExitException: Program "winget.exe" ended with non-zero exit code: -1978335212.
Error details
No response
Environment data
Name Value
---- -----
PSVersion 7.4.0-preview.4
PSEdition Core
GitCommitId 7.4.0-preview.4
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 28 (11 by maintainers)
The Engine WG reviewed this issue and agrees with @Luiz-Monad. The message can easily be updated to display the int
ExitCode
in both decimal and hexadecimal.There’s no true correct answer for this situation, really.
So I propose:
NativeCommandExitException: Program "winget.exe" ended with non-zero exit code: -1978335212 (0x8a150014).
Why not both !
because
1000000
is0x000F4240
and0x40
is64