Here are some useful and common options you can pass to your script or directly in the shebang.

They are supported by both bash and ksh.

Exit when a command fails

set -e

Exit if a variable is not set

set -u
set -x

Fail if a piped command fails

set -o pipefail

You can check with this simple example:

grep something /non/existent/file | sort