threads / discuss / 29302

Why usage function exit with code 129?

Subject: Why usage function exit with code 129?

## tl;dr

5 messages between Jan 6, 2012 and Jan 6, 2012.

replies: 4people: 2as markdown or json

徐迪· Jan 6, 2012, 07:15 UTC · lore

I did like this: $ git add --foo $ echo $? what I got is 129, should this code being used as program terminated due to a signal? Cause it's 128+1. According to this[1].

[1] http://tldp.org/LDP/abs/html/exitcodes.html
Nguyen Thai Ngoc Duy· Jan 6, 2012, 07:22 UTC · re: 徐迪 · lore

Re: Why usage function exit with code 129?

2012/1/6 徐迪 <xudifsd@gmail.com>:
Show 5 quoted lines
> I did like this:
> $ git add --foo
> $ echo $?
> what I got is 129, should this code being used as program terminated
> due to a signal? Cause it's 128+1. According to this[1].

usage() (in your case) always returns 129, die() 128. See 5d1a5c0 ([PATCH] Better error reporting for "git status")

> [1] http://tldp.org/LDP/abs/html/exitcodes.html
No it does not mean terminated by signals.
-- 
Duy
徐迪· Jan 6, 2012, 08:06 UTC · re: Nguyen Thai Ngoc Duy · lore

Re: Why usage function exit with code 129?

>> [1] http://tldp.org/LDP/abs/html/exitcodes.html
>
> No it does not mean terminated by signals.
> --

In that case, why not just use another code instead of the code that leads misunderstanding? I mean, as far as I know, exit code between 129 and 255 are used to indicate the program terminated by signal. So that usage function can only exit with code between 1 and 127. Am I wrong?

Nguyen Thai Ngoc Duy· Jan 6, 2012, 08:11 UTC · re: 徐迪 · lore

Re: Why usage function exit with code 129?

2012/1/6 徐迪 <xudifsd@gmail.com>:
Show 9 quoted lines
>>> [1] http://tldp.org/LDP/abs/html/exitcodes.html
>>
>> No it does not mean terminated by signals.
>> --
> In that case, why not just use another code instead of the code that
> leads misunderstanding? I mean, as far as I know, exit code between
> 129 and 255 are used to indicate the program terminated by signal. So
> that usage function can only exit with code between 1 and 127. Am I
> wrong?

Because that code has been there too long (since 2005) any probably all git commands, including plumbing ones, rely on it. Changing it now may break existing scripts.

-- 
Duy
徐迪· Jan 6, 2012, 08:18 UTC · re: Nguyen Thai Ngoc Duy · lore

Re: Why usage function exit with code 129?

在 2012年1月6日 下午4:11,Nguyen Thai Ngoc Duy <pclouds@gmail.com> 写道:
Show 16 quoted lines
> 2012/1/6 徐迪 <xudifsd@gmail.com>:
>>>> [1] http://tldp.org/LDP/abs/html/exitcodes.html
>>>
>>> No it does not mean terminated by signals.
>>> --
>> In that case, why not just use another code instead of the code that
>> leads misunderstanding? I mean, as far as I know, exit code between
>> 129 and 255 are used to indicate the program terminated by signal. So
>> that usage function can only exit with code between 1 and 127. Am I
>> wrong?
>
> Because that code has been there too long (since 2005) any probably
> all git commands, including plumbing ones, rely on it. Changing it now
> may break existing scripts.
> --
> Duy
Ok, that sounds logical.

← back to recent threads