views:

237

answers:

4
+1  Q: 

`ls` exit status

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?

A: 

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
A: 

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
A: 

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

Earlz
+1  A: 

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

Shadow