Skip to content

Instantly share code, notes, and snippets.

@caffeinetiger
Last active April 18, 2022 18:20
Show Gist options
  • Select an option

  • Save caffeinetiger/b13f1475737781ae0d747acd73c8b987 to your computer and use it in GitHub Desktop.

Select an option

Save caffeinetiger/b13f1475737781ae0d747acd73c8b987 to your computer and use it in GitHub Desktop.
#!/bin/bash
function exit_if_command_not_installed() {
local some_command_to_check=$1
if ! command -v $some_command_to_check &> /dev/null
then
echo "$some_command_to_check could not be found"
exit
fi
}
#!/bin/bash
if [[ -z "${SOME_ENV_VAR_OR_SCIPT_VAR}" ]]; then
echo "SOME_ENV_VAR_OR_SCIPT_VAR is not set." >&2
exit 1
fi
#!/bin/bash
if [ -z ${some_variable+x} ]; then
some_variable="some value";
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment