-z
to test if string is null (zero length)
if [ -z "$AWS_ACCOUNT_ID" ]; then
echo "AWS_ACCOUNT_ID environment variable is not set."
exit 1
fi
set -e
to stop on first error (command return with non-zero retval).set +e
to turn this off.- Reference
check_command() {
if ! [ -x "$(command -v "$1")" ]; then
echo "$1 is required to run this script"
exit
fi
}
# usage
check_command aws