Sunday 13 August 2017

Bash Exit Status With the Special Variable $?

Cited from the Book "Pro Bash Programming"

You can test the success of a command directly using the shell keywords while, until, and if or with the control operators && and ||. The exit code is stored in the special parameter $?.

If the command executed successfully (or true), the value of $? is zero. If the command failed for some reason, $? will contain a positive integer between 1 and 255 inclusive.

No comments:

Post a Comment