Skip to content

Instantly share code, notes, and snippets.

@squeedee
Created July 30, 2015 15:17
Show Gist options
  • Save squeedee/dc3f36d2bf61234d344b to your computer and use it in GitHub Desktop.
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.
#!/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
@squeedee
Copy link
Author

source env.sh creates two new env vars in your bash context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment