linux 命令返回的退出状态 1 的含义
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20965762/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Meaning of exit status 1 returned by linux command
提问by user2664054
What is meaning of exit status 1 returned by linux command? Like 127 exit status indicates "command not found".
linux命令返回的退出状态1是什么意思?像 127 退出状态表示“找不到命令”。
I have visited http://linux.die.net/abs-guide/exitcodes.htmlpage, does it mean exit status 1 does not have particular special meaning?
我访问过http://linux.die.net/abs-guide/exitcodes.html页面,是不是说退出状态 1 没有特别的特殊含义?
回答by tripleee
The only general convention is that a zero exit status signifies success, whereas any non-zero exit status is a failure.
唯一的通用约定是零退出状态表示成功,而任何非零退出状态都是失败。
Many -- but certainly not all -- command-line tools return exit code 1 for syntax error, i.e. you had too few arguments or an invalid option.
许多——但肯定不是全部——命令行工具返回退出代码 1 以表示语法错误,即参数太少或选项无效。
Many -- but, alas, not all -- command-line tools have a manual page. By convention, it should document the exit codes of the program, but many do not.
许多——但是,可惜,不是所有——命令行工具都有一个手册页。按照惯例,它应该记录程序的退出代码,但很多没有。
回答by Tajinder
You can see the value of the exit status using man
.
您可以使用 来查看退出状态的值man
。
Giving an example below:
下面举个例子:
man ls
Now search for string exit
现在搜索字符串退出
Adding screen shot below:
添加屏幕截图如下: