When going through one shell script, I saw the term "$?". What is the significance of this term?
|
|
In simpler terms, it's the exit status of the last command. |
|||
|
|
|
In addition to what cjm said, if the value of |
|||||||||
|
|
Cjm's answer is correct, but
If at all possible (readability concerns sometimes intrude) you should code this situation differently:
This latter usage is faster, does not contaminate the shell's variable namespace with what amounts to temp variables, can often be alot more readable for humans and encourages the use of "positive logic", the practice of writing conditionals without negations, which has cognitive simplicity in most situations. It does away with the use of |
|||||
|
|
|
||||
|
|