ash bug ?
Juergen Hennerich
juergen at hennerich.eu
Sun Sep 3 12:42:45 PDT 2006
walter harms schrieb:
> hi list,
> riaz and i are working on documenting ash. so i tried to run the bash test scripts on ash.
> and one place ash breaks where sh works. bug or feature ?
The (( )) (ARITHMETIC EVALUATION) is a ksh (Korn SHELL) feature which is
supported by bash but not by ash. In contrast to the arithmetic
expansion ("$(( ))") which is supported by ash the arithmetic evaluation
gives back either 0 or 1 as result of the evaluation. Also the
arithmetic expansion works different with ash which requires that
variables inside the expansion are prefixed with $ in contrast to bash.
(I just saw, that it is supported (arithmetic expansion without $) in
the busybox ash, The normal ash which is installed on most Linux systems
has a different behavior)
> ash is running endless because it does not find 'x'
>
That is completely logical.
> x=3
> until (( x == 4 )) ; do
> x=4
> done
>
> note:
>
> removing the spaces solves the problem.
>
No it does not!
Try: x=1 ; until (( x==4 )) ; do echo bla $x ; x=$(($x+1)) ; done
You'll see, that it does not, what you want it to do.
Instead you should either use:
x=1 ; until [ $x -eq 4 ] ; do echo bla $x ; x=$(($x+1)) ; done
or
x=1 ; until ( expr $x == 4 >/dev/null ) ; do echo bla $x ; x=$(($x+1)) ;
done
or
x=1 ; until let x==4 ; do echo bla $x ; x=$(($x+1)) ;
Or course the functionality could easily implemented in busybox ash,
since the functionality is already there: ((x)) <-> let x .
Juergen
> re,
> wh
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://busybox.net/cgi-bin/mailman/listinfo/busybox
>
>
More information about the busybox
mailing list