Skip to content

Instantly share code, notes, and snippets.

@NanoDano
Created June 3, 2020 21:02
Show Gist options
  • Save NanoDano/266fe6e40b0e5667bb554b28ae4e3d0e to your computer and use it in GitHub Desktop.
Save NanoDano/266fe6e40b0e5667bb554b28ae4e3d0e to your computer and use it in GitHub Desktop.
Bash check return values
# See if last statement executed was successful
./runSomething
if [ $? -eq 0 ]; then
echo OK
else
echo FAIL
fi
# The return value can also be stored as a variable
returnValue=$?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment