Skip to content

Instantly share code, notes, and snippets.

@mindscratch
Created February 26, 2014 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mindscratch/9227240 to your computer and use it in GitHub Desktop.
Save mindscratch/9227240 to your computer and use it in GitHub Desktop.
script to check for environment variables
#!/usr/bin/env bash
. /etc/init.d/functions
declare -a env_variables=(FOO BAR)
function checkVariables {
for var in "${env_variables[@]}"
do
if env | grep -q ^"$var="
then
echo -n " $var: " && success
echo
else
echo -n " $var: " && failure
echo
echo -n " "
cat env_vars/$var.md
echo
fi
done
}
echo "Checking for environment variables:"
checkVariables
// -----------------------------------
// EXAMPLE:
// output if FOO is set but BAR is not
//
// Checing for environment variables:
// FOO [ OK ]
// BAR [FAILED]
// the path to a program that should be run

the path to a program that should be run

FOO specifies the number of times to run $BAR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment