I like to use (( ))
when comparing integers in bash, but this doesn't seem possible with an exit code ($?
) without assigning it to a variable first.
This works, but I have to assign status
first:
some_command
status=$?
if (( status == 137 )); then
foo
fi
This obviously doesn't work:
some_command
if (( ? == 137 )); then
foo
fi
So I usually end up doing this:
some_command
if [[ $? -eq 137 ]]; then
foo
fi