[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: exit value
From: |
Stephen Montgomery-Smith |
Subject: |
Re: exit value |
Date: |
Mon, 15 Jul 2013 14:35:24 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 |
On 07/15/2013 11:51 AM, Vytautas Jancauskas wrote:
> On Mon, Jul 15, 2013 at 7:44 PM, c. <address@hidden> wrote:
>> Hi,
>>
>> I'm not sure whether this is expected behaviour so I am asking before filing
>> a bug.
>>
>> The following work as I expect:
>> $ octave-cli -q --norc --eval "exit (0)"; echo $?
>> 0
>> $ octave-cli -q --norc --eval "exit (1)"; echo $?
>> 1
>> $ octave-cli -q --norc --eval "exit (177)"; echo $?
>> 177
>>
>> but the ones below look surprising:
>>
>> $ octave-cli -q --norc --eval "exit (-177)"; echo $?
>> 79
>> $ octave-cli -q --norc --eval "exit (-1)"; echo $?
>> 0
>>
>> is this the way it is supposed to work?
>>
>> c.
>
>
> Exit values are interpreted as unsigned integers by the shell. The
> following code will print 79 as well.
>
> int main()
> {
> unsigned char x;
> x = -177;
> printf("%d\n", x);
> }
>
>
Yes, but shouldn't -1 print as 255?