Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のようにxtermを使用してコマンド(私の場合は別のスクリプト)を呼び出すと、次のようになります。
xterm -e sh second.sh
xtermが戻った後の値は$?、xtermの終了ステータスコード(通常は私にとっては0)であり、スクリプトではありません。
$?
スクリプトの終了ステータスコードを取得する方法はありますか?
次のようなことができます。
statusfile=$(mktemp) xterm -e sh -c 'yourcommand; echo $? > '$statusfile status=$(cat $statusfile) rm $statusfile
の終了ステータスはyourcommandvariable になりstatusました。
yourcommand
status