You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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
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 togit.exe
, but fails if it resolves togit.ps1
.This is surprising behavior, and makes the shims a leaky abstraction over the command they represent.
Steps to reproduce
Get-Command git
and verify that theName
property isgit.ps1
git status
$?
variable isTrue
git.ps1
shimGet-Command git
and verify that theName
property isgit.exe
$?
variable isFalse
The text was updated successfully, but these errors were encountered: