Created
February 26, 2013 19:11
-
-
Save jesperronn/5041153 to your computer and use it in GitHub Desktop.
isDefined() unix method to determined if a variable exists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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