`ls` exit status
Asked Answered
A

4

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?

Agronomics answered 18/6, 2009 at 5:41 Comment(2)
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.Retinoscope
Sorry about that - it'll be done in a second.Agronomics
A
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)

Agronomics answered 22/6, 2009 at 17:37 Comment(0)
E
1

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

Elsyelton answered 18/6, 2009 at 5:52 Comment(0)
X
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.

Xever answered 18/6, 2009 at 5:48 Comment(0)
C
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
Cacomistle answered 18/6, 2009 at 5:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.