What is the max value $? could return?

What is the max value $? could return?

am 16.11.2007 15:07:41 von raymond

Hello,

Is it true that $? could only return max 255? How if I want an exit
value larger than 256?

Thanks,

Raymond

Re: What is the max value $? could return?

am 16.11.2007 15:22:22 von Janis Papanagnou

On 16 Nov., 15:07, Raymond wrote:
> Hello,
>
> Is it true that $? could only return max 255?

No, it's depending on the shell (and its version) and may also be just
127. Also note that a couple of the values already have predefined
meanings. Ksh93 for example uses values larger than 256 to code exits
"by signal".

> How if I want an exit
> value larger than 256?

You can let your script print the number and indicate it to the caller
by some fixed exit code.

Janis

> Thanks,
>
> Raymond

Re: What is the max value $? could return?

am 16.11.2007 15:25:15 von Icarus Sparry

On Fri, 16 Nov 2007 06:07:41 -0800, Raymond wrote:

> Hello,
>
> Is it true that $? could only return max 255? How if I want an exit
> value larger than 256?
>
> Thanks,
>
> Raymond

We can tell you this just as soon as you tell us how to store a value
larger than 255 in 8 bits.

Look at the "wait" and related system calls and structures.