Is it possible to get the exit code from a subshell?

后端 未结 3 1980
情歌与酒
情歌与酒 2021-02-05 03:01

Let\'s imagine I have a bash script, where I call this:

bash -c \"some_command\"
do something with code of some_command here

Is it possible to

3条回答
  •  没有蜡笔的小新
    2021-02-05 03:58

    $? will contain the return code of some_command just as usual.

    Of course it might also contain a code from bash, in case something went wrong before your command could even be executed (wrong filename, whatnot).

提交回复
热议问题