The exit code of the original shell script

Shell scripts can be fetched, i.e. executed in the current shell, for example

. ~/some_script.sh

      

but they can also be called through a subshell, for example.

/bin/bash ~/another_script.sh

      

Having written one script, I changed my schema from source to subshell and then back to source. There are things that make writing different. And now I'm stuck with exit statuses, you are not sure - do return

statuses interfere with the ones it produces exit

? The reason is tldp is written, some statuses are reserved, but all examples refer to the directive exit

. So what are these restrictions also associated with return codes?

All usefull I found in the ABS manual is command A return

, which optionally takes an integer argument, which is returned to the calling script as the "exit status" for the function, and this exit status is assigned to the variable $?. But Im in doubt about the status " like quotes around. "

+3


source to share


1 answer


The codes returned with return

and exit

are identical, keywords are used only in different contexts ( return

to return from functions and sources, exit

to exit the current shell).



They do not interfere with each other as such, but with exit

or return

without an argument will use the return value of the previous command, which can be specified in others exit

or return

assertion.

0


source







All Articles