0

In my code, when I do

echo $?

It returns to me a value of 127. I thought it only returns either a 1 for failure or a 0 for success? What does a value of 127 mean?

jj172
  • 751
  • 2
  • 9
  • 35

1 Answers1

4

$? is the return value of the previous command. The convention is that 0 is "OK" and anything else signals an error. Different errors can send different values, and thus the calling process(usually the shell) can distinguish between different errors.

As for the meaning of 127 specifically see here: 127 Return code from $?

Community
  • 1
  • 1
Erik Vesteraas
  • 4,675
  • 2
  • 24
  • 37
  • 1
    Exit codes with special meanings: http://tldp.org/LDP/abs/html/exitcodes.html#EXITCODESREF – Ken Sep 11 '14 at 22:46