unknown operand in ash

Vladimir N. Oleynik dzo at simtreas.ru
Fri Apr 21 10:43:32 UTC 2006


Alexander,

> I wrote a small shell script for CGI Post Method handling and one part
> of this script is this line:
> 
> [ "$REP" = "%" ] && REP="%%"
> 
> This works fine, as long as $REP is not "!".
> 
> [lxtc - ~ #] REP=%
> [lxtc - ~ #] [ "$REP" = "%" ] && echo test
> test
> [lxtc - ~ #] REP=x
> [lxtc - ~ #] [ "$REP" = "%" ] && echo test
> [lxtc - ~ #] REP=!
> [lxtc - ~ #] [ "$REP" = "%" ] && echo test
> [: %: unknown operand

You can see - its error produced by "test" applet, is not ash ;-)

> [lxtc - ~ #]
> 
> According to ash.c this happens because ash thinks that the leading
> ! has to be used as operand.
> 
> For the meantime, I helped my self out by modifying the line to the
> following statement:
> 
> [ "x$REP" = "x%" ] && REP="%%"

Yes. Its recomended a solution.


--w
vodz



More information about the busybox mailing list