From: Stephane CHAZELAS on 8 Apr 2010 08:44 2010-04-08, 12:14(+00), Casper H.S Dik: [...] >>foo=1+1 >>rc=foo >>[ "$rc" -ne 0 ] > >>will return true, so would [ "$rc" -eq 2 ]. > > except when foo isn't a variable in which case "$rc" evaluates > to 0. [...] foo is an unset variable which expands the same as an empty variable, and in numeric contexts, the empty string means 0. It's different from the Bourne shell even if it leads to the same result in this very case. unset foo rc='2*foo+1' [ "$rc" -eq 1 ] is true in ksh -- Stéphane
First
|
Prev
|
Pages: 1 2 Prev: What's the equivalent of the RE: \d+[+-]? Next: Change Case of Word Using VI |