【发布时间】:2014-09-14 11:55:38
【问题描述】:
在终端中我可以轻松获取命令的错误代码
> cat thisdoesntexist
cat: thisdoesntexist: No such file or directory
> echo $?
1
但是当我在新终端中运行命令时也会这样做
> gnome-terminal -e "cat thisdoesntexist"
> echo $?
0
第二种情况下如何获取命令的错误码(使其返回1)?
【问题讨论】:
标签: bash terminal error-code