Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Last active January 31, 2025 11:37
Show Gist options
  • Select an option

  • Save wilmoore/72e7bc9106f923d8b450a11525f352f9 to your computer and use it in GitHub Desktop.

Select an option

Save wilmoore/72e7bc9106f923d8b450a11525f352f9 to your computer and use it in GitHub Desktop.
Software Engineering :: Operating Systems :: Linux :: Command :: Shell :: Exit Status

Software Engineering :: Operating Systems :: Linux :: Command :: Shell :: Exit Status

⪼ Made with 💜 by Polyglot.

related

The exit status of an executed command is the value returned by the waitpid system call or equivalent function. Exit statuses fall between 0 and 255, though, as explained below, the shell may use values above 125 specially. Exit statuses from shell builtins and compound commands are also limited to this range. Under certain circumstances, the shell will use special values to indicate specific failure modes.

All of the Bash builtins return an exit status of 0 if they succeed and a non-0 status on failure, so they may be used by the conditional and list constructs.

All builtins return an exit status of 2 to indicate incorrect usage, generally invalid options or missing arguments.

  • a command which exits with a 0 exit status has succeeded
  • An exit status non-0 indicates failure
  • If a command is not found, the child process created to execute it returns a status of 127
  • If a command is found but is not executable, the return status is 126.
  • If a command fails because of an error during expansion or redirection, the exit status is greater than zero.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment