I have an
if [ $? -eq 0 ]
echo "err A is $?"
echo "DO THIS"
echo "Do THAT"
'[' 1 -eq 0 ']'
echo 'err A is 1'
err A is 1
echo, being the last command of the condition, is what
if tests to determine which branch to take. Try this instead:
if rv=$?; echo "err A is $rv"; [ "$rv" -eq 0 ]; then
Note that in your original, the value of
$? in your
echo command is the result of the
[ that immediately precedes it, not the value that