Skip to content

Instantly share code, notes, and snippets.

@morganp
Created June 11, 2011 00:57
Show Gist options
  • Save morganp/1020125 to your computer and use it in GitHub Desktop.
Save morganp/1020125 to your computer and use it in GitHub Desktop.
#!/bin/bash
#VAR is then name of the variable to look for
VAR=$1
eval test=\${$VAR}
if [ "$test" == "" ]
then
echo "Enviroment Variable $VAR has not been set"
echo "enter value then press return"
#CAPTURE='test'
read -e CAPTURE
# Set it now in the Enviroment
#export $VAR=$CAPTURE
#echo "export $VAR='$CAPTURE'"
# Add to bashrc so will it be set next time
echo "export $VAR=$CAPTURE" >> ~/.bashrc
else
echo "$VAR is set to $test"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment