Created
May 1, 2013 20:45
-
-
Save srathbun/5498235 to your computer and use it in GitHub Desktop.
Magic portable indirect references for shell.
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
setref() | |
{ | |
if [ -n "$1" ]; then | |
eval $1=$2 | |
else | |
echo "Null parameter passed to this function" | |
fi | |
} | |
deref() | |
{ | |
if [ -n "$1" ]; then | |
localvar=$(eval echo \$$1) | |
echo "${localvar}" | |
else | |
echo "Null parameter passed to this function" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment