在 bash 中
$ git status > /dev/null; echo $?
0
Powershell 中的相同存储库
$> (Start-Process git -ArgumentList="status" -Wait -PassThru).ExitCode
129
这是怎么回事,129
是什么意思,为什么它不等于 0
以及如何让它正确?
最佳答案
当您错误地指定 git
的参数(并且需要打印其用法)时,它将退出并显示错误代码 129:
C:\Temp>git status --asdf
error: unknown option `asdf`
usage: git status [options] [--] <filepattern>...
.... help is printed here ....
C:\Temp>echo %ERRORLEVEL%
129
您是否有可能错误地通过 PowerShell 传递命令? (例如,-Wait -Passthrough
是否被传送到 git-status
?)
您可以通过调用 git-status
命令而不是使用 status
参数调用 git
来完全避免传递参数。
关于git - Start-Process "git"返回奇怪的 129 退出代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21733440/