Exit status

Updated: 06/22/2018 by Computer Hope

Illustration: exit status.Also referred to as an exit code or a result code, an exit status is the number returned by a computer process to its parent when it terminates. Its purpose is to indicate either that the software operated successfully, or that it failed somehow.

The value of an exit status is an integer. Usually, the value 0 indicates that the exiting process was successful, and 1 (or greater) indicates that it failed.

In Microsoft Windows and MS-DOS, exit status is called errorlevel.

In the bash shell, errorlevel may be accessed by the special environment variable ?, for example:

true; 
if [ $? -eq 0 ]; then 
  echo "True."; 
else 
  echo "Wait, shouldn't that be true?"; 
fi
True.

Script, Batch file, true (Linux command), false (Linux command)