I have a bash script (script A) which runs a secondary bash script (script B).
sh scriptB.sh
exitStatus = ?
I need to get the exit code of the script B when I run it inside script A.
How can I do?
See 3.4.2 Special Parameters of the Bash Reference Manual.
The shell treats several parameters specially. These parameters may only be referenced; assignment to them is not allowed.
?
($?) Expands to the exit status of the most recently executedforeground pipeline.
exitStatus="$?"