Unix/Linux: How to check the exit status of a command in a shell script

As a quick note, here’s part of a Unix/Linux shell script that demonstrates some scripting syntax, including the if/then syntax, and how to check the exit status of a command-line application:

/bin/sh

echo "Running 'sbt assembly' ..."
sbt assembly
if [ $? != 0 ]
then
  echo "SBT-ASSEMBLY FAILED, STOPPING BUILD PROCESS"
  exit 1
fi
echo "\n"

I don’t have much to add to that, other than to say that an exit status of 0 is good, and anything other than 0 means the command failed. I can just never remember the shell’s if/then syntax, so that’s why I’m putting this here (for myself).