bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: is this a bug?


From: Pierre Gaston
Subject: Re: is this a bug?
Date: Wed, 14 Nov 2007 11:26:27 +0200

On Nov 14, 2007 7:26 AM, naruto canada <address@hidden> wrote:
> function fact {
>   local n=$1
>   if [ "$n" -eq 0 ]; then
>     return 1
>   else
>     fact $(( $n - 1 ))
>     return $(( $n * $? ))
>   fi
> }
>
> for i in `seq 0 11`; do
> fact $i ; echo $?
> done
>
>
> 1
> 1
> 2
> 6
> 24
> 120
> 208
> 176
> 128
> 128
> 0
> 0
>
> the results are wrong for 6 and above.
> is this a bug?
>
It's not a bug. the exit status of a command, the "return" of your
function, is limited to the numbers 0-255.
You need to either use the output of your function or a global
variable if you want more than that.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]