You should do
if ARG=false
Then use $ARG not $? in the if statement.
I can't think of an example of the if statement being confusing that isn't relying on $?
error=0 if ! some_command; then error=$?; bar; fi echo "blah" return $error
Status=0
Somecommand || status=$?
Then do logic based on status
You should do
if ARG=false
Then use $ARG not $? in the if statement.