Closed rlove closed 2 years ago
run
cmd.exe /c "exit 44"
expected errorexit.code > 0
actualexit.code == 0
I cannot reproduce this case on my end. The exit code is 44 as expected.
EDITED: $global:LASTEXITCODE
may have been changed by something other than the prompt
function defined by Oh My Posh.
@rlove which version of PowerShell Core is this? We did a lot of work on this as indeed, it's not very straightforward, but if @lewis-yeung can't reproduce it (who did amazing work on the PowerShell) we're a bit stuck. Do you still have this behavior with a clean profile that only initializes oh-my-posh?
@lewis-yeung & @JanDeDobbeleer thank you. The problem is specific to something in my profile. When I comment out everything other than oh-my-posh in my profile it works fine. I suspect I did not remove 100% of my custom prompt code that I wrote, which did work with $LASTEXITCODE
Thanks for producing something that allows me to ditch my custom code.
This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.
Code of Conduct
What happened?
Running these 3 commands in a new powershell core (on windows OS) session.
run
cmd.exe /c "exit 0"
expected errorexit.code == 0
actualexit.code == 0
runcmd.exe /c "exit 44"
expected errorexit.code > 0
actualexit.code == 0
runthrow "asdf"
expected errorexit.code > 0
actualexit.code > 0
I think it's due to the strange way exit codes for external processes can work in powershell. https://stackoverflow.com/questions/57468522/powershell-and-process-exit-codes
Theme
What OS are you seeing the problem on?
Windows
Which shell are you using?
powershell
Log output