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

The Shell: arithmetic comparison with void



If was time, where string comparisons with void were ... with features.

|-*-
if [ "x$a" = 'x|' ]; then
|-*-

Yet arithmetic ones are still with them:

|-*-	       
olecom@flower:/tmp$ bash -c "test '' -eq 0 ; echo \$?"
bash: line 0: test: : integer expression expected
2
olecom@flower:/tmp$ dash -c "test '' -eq 0 ; echo \$?"
0
olecom@flower:/tmp$ busybox sh -c "test '' -eq 0 ; echo \$?"
0
olecom@flower:/tmp$
|-*-

Ah, bash is clever?

|-*-
olecom@flower:/tmp$ bash -c -v "test \"printf '\t'\" -eq 0 ; echo \$?"
test "  " -eq 0 ; echo $?
0
olecom@flower:/tmp$ bash -c -v "test \"printf ' '\" -eq 0 ; echo \$?"
test " " -eq 0 ; echo $?
0
olecom@flower:/tmp$ bash -c -v "test \"printf 'a'\" -eq 0 ; echo \$?"
test "a" -eq 0 ; echo $?
bash: line 0: test: a: integer expression expected
2
olecom@flower:/tmp$
|-*-

Nope?

Are there bugs or features?
____


-- 
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


Reply to: