I know the return code will be contained in $? after a command was executed, but what does $? mean after a script was executed? The return code of the last command in that script?
Can I tell if a script has been excuted from head to tail and not interrupted by some unexpected system halt or something?
If I have a script like below excuted,
Command A;
if [ $? -eq 0]
then
echo "OK" >> log
else
echo "failed" >> log
fi
and the system halted while A was running, what will I find in that log file? "OK", "failed" or nothing?
Yes, or the value passed after exit, e.g. exit 31.
Not without taking measures within the other script to make it explicit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With