title: Does a bash script have return code itself?
body: <p>I know the return code will be contained in <code>$?</code> after a command was executed, but what does <code>$?</code> mean after a script was executed? The return code of the last command in that script?</p>
  
  <p>Can I tell if a script has been excuted from head to tail and not interrupted by some unexpected system halt or something?</p>
  
  <p>If I have a script like below excuted,</p>
  
  <pre><code>Command A;
  if [ $? -eq 0]
  then
  echo "OK" &gt;&gt; log
  else
  echo "failed" &gt;&gt; log
  fi
  </code></pre>
  
  <p>and the system halted while <code>A</code> was running, what will I find in that log file? "OK", "failed" or nothing?</p>