Last active
June 16, 2018 06:16
-
-
Save pulkitsinghal/e37823df90e6f87f3d3f25b1cfe1cdc0 to your computer and use it in GitHub Desktop.
Read the .env file and setup the environment variables for local testing
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/sh | |
# This script is used to read the .env file and setup the enviroment variables for local testing | |
echo "###" | |
echo Its best to invoke this script as: '. ./setenv.sh' rather than './setenv.sh' | |
echo "###" | |
while read kv | |
do | |
key=${kv%%=*} | |
val=${kv#*=} | |
if [[ "$key" == \#* ]]; then | |
echo skipping comments | |
elif [[ "$key" == "" ]]; then | |
echo skipping empty line | |
else | |
echo export $key="$val" | |
export $key="$val" | |
fi | |
done < ".env" | |
echo "###" | |
echo Its best to invoke this script as: '. ./setenv.sh' rather than './setenv.sh' | |
echo "###" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@kamal0808 - i fixed the env file reader, I may not be able to check it into our work projects for a while so please use it from over here by copy/pasting when you need it.