[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
math. operation on empty variables
From: |
Juerg . Oehler |
Subject: |
math. operation on empty variables |
Date: |
Mon, 26 Jul 2004 18:22:08 +0200 |
hi,
i am about to program sh scripts based on xpg4 / posix / bourne-sh.
now i made out a difference in behavior, which i would like to show you.
the script is more then simple:
>>>>>>
if [ "$FORCE" -eq 0 ] ; then
echo "don't force"
else
echo "force"
fi
>>>>>>
here are the results:
>/usr/bin/jsh test.sh #sun's bourne-sh
don't force
>/usr/xpg4/bin/sh test.sh #sun's xpg4 / posix sh
don't force
>/usr/bin/ksh test.sh
don't force
>/usr/local/bin/bash test.sh
test.sh: [: : integer expression expected
force
>/usr/local/bin/bash --posix test.sh
test.sh: [: : integer expression expected
force
questions:
- is there any reason for NOT substitute null values to 0 for integer
expressions?
- would be nice posix sh behave the same? (although posix does not define a
lot)
- why do we get the result force after errormsg?
thx for answer
have fun and a nice day.
george
_________________________________________
IDZ EDI
Informatik-Dienstleistungszentrum EDI
Jürg Oehler
Güterstrasse 24, CH-3003 Bern
Telefon: IDZ +41 31 323 41 50
BAR +41 31 322 97 62
mailto:address@hidden
- math. operation on empty variables,
Juerg . Oehler <=