Gen. Question - Script calls multiple programs - Return Code Handling?

General Question: If a script calls multiple external programs (external to the script, but still on unix), where do the return codes go? Let's say one of external programs fails, does the entire script fail and send a non-zero return code to the job scheduling software, or is the return code sent to the script itself?

My hunch, or slight remembrance is the script itself, but not sure.

Thanks

The return code comes back to the calling script or the command line.
If you call several external programs (or commands like sed) the last command in the pipeline generates the return code.

external_prog
echo "this is the return code from external prog $?"

grep  'junk' somefile | sort -u | wc -l
echo "this is the return code from wc -l $? the others are not available easily"

[[ -d mydirectory ]] || mkdir mydirectory && echo "created mydirectory"
echo " I cannot tell whose return code I am getting"

nohup prog1 2>&1 &
nohup prog2 2>&1 &
wait
echo " I am getting the return code from wait"