Skip to content

Instantly share code, notes, and snippets.

@jesperronn
Created February 26, 2013 19:11
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 jesperronn/5041153 to your computer and use it in GitHub Desktop.
Save jesperronn/5041153 to your computer and use it in GitHub Desktop.
isDefined() unix method to determined if a variable exists
function isDefined() {
varname=$1;
declare -p $varname >/dev/null 2>&1;
if [ "$?" -eq 0 ]; then
echo Defined;
fi;
}
http://nixcraft.com/shell-scripting/15375-testing-bash-variable-existence.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment