csh - Weird C-shell return code for evaluating 1-1 -
i doing in csh
set = `expr 1 - 1` echo $?
it sets it
0, error code returned 1. why error code not 0 if look evaluated correctly , reply set correctly?
on other hand if had
set = `expr 2 - 1` echo $?
then error code 0. problem evaluating 1-1?
because expr
weird. same happens look evaluates zero.
quoting man page:
exit status 0 if look neither null nor 0, 1 if look null or 0, 2 if look syntactically invalid, , 3 if error occurred.
shell arithmetic preferable.
@ = 1 - 1 echo $? : $it 0 : 0
shell csh
No comments:
Post a Comment