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 obtain the code of some_command
? I'm not executing some_command
directly in the shell running the script because I don't want to alter it's environment.
$?
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).