开始处理"git".返回奇怪的129退出代码 [英] Start-Process "git" returns strange 129 exit code

查看:80
本文介绍了开始处理"git".返回奇怪的129退出代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Bash中

$ git status > /dev/null; echo $?
0

Powershell中的相同存储库

Same repository in Powershell

$> (Start-Process git -ArgumentList="status" -Wait -PassThru).ExitCode
129

这是怎么回事, 129 是什么意思,为什么它不等于 0 ,以及如何正确处理?

What is going on here, what 129 means and why it is not equal to 0 and how to get it right?

推荐答案

如果您错误地为 git 指定参数(并需要打印其用法),它将退出并显示错误代码129:

When you specify the arguments to git incorrectly (and needs to print its usage) it will exit with error code 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 ?)

Is it possible that you are passing the commands through PowerShell incorrectly? (Eg, is -Wait -Passthrough being delivered to git-status?)

您可以避免完全通过传递参数来实现,方法是调用 git-status 命令,而不是使用 status 参数调用 git .

You could avoid passing arguments entirely by calling the git-status command instead of calling git with the status argument.

这篇关于开始处理"git".返回奇怪的129退出代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆