Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.ps1 shim for Git masks command failure ($? is True, $LASTEXITCODE is non-zero) #4003

Closed
gavinfoley opened this issue May 30, 2020 · 1 comment

Comments

@gavinfoley
Copy link

What's the issue?

When running a Git command which fails, I want to check for that failure using the $? variable. (More concretely, I'd like to use it implicitly with the && operator added in PowerShell 7.)

This works as expected if the git command resolves to git.exe, but fails if it resolves to git.ps1.

This is surprising behavior, and makes the shims a leaky abstraction over the command they represent.

Steps to reproduce

  • Run Get-Command git and verify that the Name property is git.ps1
  • In a directory which is not a Git repository, run a Git command such as git status
  • Observe that the value of the $? variable is True
  • Remove or rename the git.ps1 shim
  • Run Get-Command git and verify that the Name property is git.exe
  • Run the same command as above in the same directory
  • Observe that the value of the $? variable is False
@gavinfoley gavinfoley changed the title .ps1 shim for Git masks command failure ($? is True, $LASTEXITCODE is non-zero) .ps1 shim for Git masks command failure ($? is True, $LASTEXITCODE is non-zero) May 30, 2020
@rashil2000
Copy link
Member

Merged in develop branch - #4543

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants