bash 启动进程“git”返回奇怪的 129 退出代码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21733440/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 09:33:06  来源:igfitidea点击:

Start-Process "git" returns strange 129 exit code

gitbashpowershell

提问by ДМИТРИЙ МАЛИКОВ

In Bash

在 Bash 中

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

Same repository in Powershell

Powershell 中的相同存储库

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

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

这里发生了什么,什么129意思,为什么不等于0以及如何正确处理?

回答by Edward Thomson

When you specify the arguments to gitincorrectly (and needs to print its usage) it will exit with error code 129:

当您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

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

您是否有可能错误地通过 PowerShell 传递命令?(例如,-Wait -Passthrough正在交付给git-status?)

You could avoid passing arguments entirely by calling the git-statuscommand instead of calling gitwith the statusargument.

你可以完全避免通过调用传递参数git-status的命令,而不是调用gitstatus参数。