Created
July 30, 2015 15:17
-
-
Save squeedee/dc3f36d2bf61234d344b to your computer and use it in GitHub Desktop.
Demonstrating progrmattic assigns to env vars in a script that can be sourced.
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
#!/bin/bash | |
VARNAMES=(FRED BOB) | |
VARVALS=('foo' 'bar') | |
index=0; | |
for name in ${VARNAMES[@]}; do | |
echo $index | |
echo $name | |
val=${VARVALS[$index]} | |
echo $val | |
export $name=$val | |
index=$((index + 1)) | |
done | |
env | grep FRED |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
source env.sh
creates two new env vars in your bash context.