Return an exit code without closing shell

前端 未结 5 1078
后悔当初
后悔当初 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 12:51

    You can use x"${BASH_SOURCE[0]}" == x"$0" to test if the script was sourced or called (false if sourced, true if called) and return or exit accordingly.

提交回复
热议问题