Closed lmarkov closed 8 years ago
I based my exit codes on some tests, but it looks like they are not the same for all commands.
Example:
~$ ls qweqwe
ls: cannot access qweqwe: No such file or directory
~$ echo $?
2
and
~$ cd qweqwe
-bash: cd: qweqwe: No such file or directory
~$ echo $?
1
I will correct the cd exit code, as well as the "command not found".
Thanks for reporting this.
Yes, there are different codes. For example: http://tldp.org/LDP/abs/html/exitcodes.html
Can you suggest how can I fix it and make exception for example when I type
# blabla
-bash: blabla: command not found
# echo $?
127
to except this error. I use additional script which creates tickets when some command or path is forbidden but I don't want to receive information for such errors every time. It could be useful this codes to be more flexible and may be to be included in the configuration files.
There is a inconsistency between bash(1) and sh(1) on the cd built-in exit code.
On sh(1):
$ cd qweqwe
sh: 5: cd: can't cd to qweqwe
$ echo $?
2
On bash(1):
~$ cd qweqwe
-bash: cd: qweqwe: No such file or directory
~$ echo $?
1
The bash documentation seems to point to an exit code of 2: http://tldp.org/LDP/abs/html/exitcodes.html
So I decided to keep the exit code provided by the python os.chdir function, for consistency.
Otherwise, I will be correcting the other exit code in my next commit.
Hello, Can you tell me how work the exit codes from shell commands? I saw that there is some kind of rewriting but may be I have mistake.
I want to filter the real shell exit codes but in python I get only 0 or 1 as a result.