Understand Exit Statuses in Bash
Every command in bash returns an exit status, which is an integer between 0 and 255 that represents whether the command succeeded or failed, and if it failed, what kind of error occurred. Functions also can return an exit status via the
return keyword. The exit status can be checked using bash's special
$? variable, which always stores the exit status of the last command run.