pwsh as a dotnet global tool doesn't return the exit code correctly
See original GitHub issueSteps to reproduce
On Linux, install PowerShell global tool as per the blog post from the PowerShell team:
https://devblogs.microsoft.com/powershell/introducing-powershell-as-net-global-tool/
dotnet tool install --global PowerShell
Then, run from bash:
pwsh "exit 1"; echo $LASTEXITCODE
Note: I’m not using -C
because of issue #10355.
Expected behavior
It outputs 1
.
Actual behavior
It outputs 0
.
Environment data
$PSVersionTable:
Name Value
---- -----
PSVersion 6.2.2
PSEdition Core
GitCommitId 6.2.2
OS Linux 4.4.0-18362-Microsoft #1-Microsoft Mon Mar 18 12:02:00 PST 2019
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Remarks
This works as expected on Linux if pwsh is not installed as a dotnet global tool.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Troubleshoot .NET tool usage issues
If you're trying to run a global tool, check that the PATH environment variable on your machine contains the path where you installed...
Read more >Why won't the "Exit" function work in my PowerShell code?
If you execute a script from the outside via PowerShell's CLI (e.g., pwsh -File script.ps1 ), the exit code set via exit $exitCode...
Read more >Powershell Exit Code 1 = Get Output Failed - Forum
I having a tough time getting my script to correctly report the exit code to SAM 6.1.1. ... Exit codes 0 and 3...
Read more >Installing PowerShell with one line as a .NET Core global tool
Tool 'powershell' (version '6.2.2') was successfully installed. ... Type 'help' to get help. PS /mnt/c/Users/Scott/Desktop> exit.
Read more >Steps to return error codes on Powershell scripts
Steps to return error codes on Powershell scripts: Use the command Exit $LASTEXITCODE at the end of the powershell script to return the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mklement0 yes! I fixed the description.
Is there a workaround for this somehow?