Return an exit code without closing shell

前端 未结 5 1092
后悔当初
后悔当初 2021-01-01 12:39

I\'d like to return an exit code from a BASH script that is called within another script, but could also be called directly. It roughly looks like this:

#!/b         


        
5条回答
  •  滥情空心
    2021-01-01 13:09

    Use this instead of exit or return:

    [ $PS1 ] && return || exit;
    

    Works whether sourced or not.

提交回复
热议问题