Skip to content

Instantly share code, notes, and snippets.

@srathbun
Created May 1, 2013 20:45
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 srathbun/5498235 to your computer and use it in GitHub Desktop.
Save srathbun/5498235 to your computer and use it in GitHub Desktop.
Magic portable indirect references for shell.
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