From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2)
Description of problem:
As above; using let to increase the value of a variable by one for
which the variable is either undefined or containing a value of zero
the exit statis is 1 even though the variable increment accurs correctly.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1.bob=0 (or unset bob)
Actual Results: prints "1"
Expected Results: should print "0"; as well because it does not exit
cleanly it causes environments using execfail to bail out prematurely.
Alternate methods appear to work (eg. bob=0; bob=$((bob + 1)); echo
$?); though having to go back and find all of what AFAIK should be
working code to this alternate is not ideal and likely to cause
problems outside of hwcert (my particular interest in this bug).
I set the sev. to high since it causes the USB test to bail out early;
though please set accordingly if this does not seem appropriate.
perhaps a nueance of evaluation order as 'let ++bob' also exits zero?
should also mention that in either case $bob contains the correct
value; if ++bob is more correct and bob++ is incorrect should it not
not of effected the value of $bob since the command is invalid?;
alternatively I would have to argue that the exit code in either case
should be 0 if the command executes correctly; oh well. Let me know
which is which.
As documented in the man page. bob++ evaluates to 0, and so 1 is
I'm still confused on how 0 + 1 evaluates to 0 while 1 + 0 evaluates
to 1; but if say so. Course I never understood... unset bob; [ -n bob
]; echo $? (returns 0); bob=foo; [ -n bob ]; echo $? (returns 0) either :)
let arg [arg ...]
Each arg is an arithmetic expression to be evaluated (see
ARITHMETIC EVALUATION). If the last arg evaluates to 0, let
returns 1; 0 is returned otherwise.