5

EDIT: nothing to see here!!! 127 return means the command wasn't found - had to give an absolute path to the command for some reason :/ (I didn't delete in case someone else has this problem)

Is there a reference of return statuses for common Linux functions like ls? (it doesn't seem to be in the man pages, at least for ls). If not, can someone tell me what ls returning 127 means?

Sinan Ünür
  • 116,958
  • 15
  • 196
  • 339
Alex S
  • 25,241
  • 18
  • 52
  • 63
  • Could you include the edit above in an answer below. Once that's done, you can mark that as the answer to this question and it will no longer appear in the Unanswered questions list. – Andy Jun 22 '09 at 16:36
  • Sorry about that - it'll be done in a second. – Alex S Jun 22 '09 at 17:36

4 Answers4

3

127 is the error for command not found. In this case, I just had to use an absolute path to the command (/bin/ls)

Alex S
  • 25,241
  • 18
  • 52
  • 63
1

as per http://www.opengroup.org/onlinepubs/009695399/utilities/ls.html a return value of 0 means success, anything >0 is an error

Earlz
  • 62,085
  • 98
  • 303
  • 499
0

ls is not a Bash function. It is an external utility. On Linux, ls is part of the GNU File Utilities. man ls should show you similar information as http://www.gnu.org/software/coreutils/manual/html_node/ls-invocation.html where the only possible values for its exit status are defined as 0, 1 and 2.

Sinan Ünür
  • 116,958
  • 15
  • 196
  • 339
0

for ls: "Exit status is 0 if OK, 1 if minor problems, 2 if serious trouble."

Source: UNIX man pages : ls

I suspect your options to find this out generally are:

  1. man
  2. Google
  3. source code analysis
Jeffrey Kemp
  • 59,135
  • 14
  • 106
  • 158