Exit status

Updated: 11/13/2018 by Computer Hope
Illustration: exit status.

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

Batch file, Programming terms, Script