如果我用xterm调用一个命令(在我的情况下是另一个脚本),如下所示:
xterm -e sh second.sh
Run Code Online (Sandbox Code Playgroud)
$?xterm返回后的值是xterm的退出状态代码(通常为我0)而不是我的脚本.
反正有没有得到我的脚本的退出状态代码?
You could do something like this:
statusfile=$(mktemp)
xterm -e sh -c 'yourcommand; echo $? > '$statusfile
status=$(cat $statusfile)
rm $statusfile
Run Code Online (Sandbox Code Playgroud)
The exit status of yourcommand is now in variable status.