Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I understand that if I execute a command in the shell with the ampersand operators e.g. command1&&command2 and should the first command execute successfully it does so with a zero exit status.

Is this similar or different to that of boolean logic whereby 0 is false and 1 is true or have I understood it incorrectly?

Does the type of shell you use make a difference? I am currently running the Bourne-Again Shell.

share|improve this question
up vote 1 down vote accepted

Shell mostly is 0 to indicate zero errors and success, so yes in this sense it is true logically, unlike in many programming languages where 0 usually is false. Although modern languages tend to have distinct logical values of true and false these days.

share|improve this answer
All the shells I know. I said mostly because I do not know all the shells. – johnshen64 Apr 30 '12 at 2:20
Thanks. How does this differ to a non-zero exit status for example when using control operators such as || in command such as command1||command2? – PeanutsMonkey Apr 30 '12 at 2:21
It means if command1 fails then execute command2, that is command1 exit status is nonzero. – johnshen64 Apr 30 '12 at 2:22
Wonder why they chose the opposite representation of boolean values. – PeanutsMonkey Apr 30 '12 at 2:55
Here is a good explanation, but as to why only mr. Bourne who developed the original grandfather of all shells would know. I guess it just means 0 or no error, thus success, thus true. – johnshen64 Apr 30 '12 at 3:41

The better rationale is that there is really only one 'success', but there are multiple reasons for a 'failure': file not found, argument error, computational error, etc. This was a convention of the OS, not just of the shell, in the interprocess communications - the return code sent by the exit(2) system call and received by the wait(2) call.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.