Last active
November 29, 2015 04:41
-
-
Save hjr265/9703857 to your computer and use it in GitHub Desktop.
Reads each line from .env file in the current directory and exports key=value to environment
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 | |
name=${1:-.env} | |
while read -r line | |
do | |
line=`echo "$line" | sed -e 's/^ *//' -e 's/ *$//'` | |
if [[ X"" = X"$line" ]] | |
then | |
continue | |
fi | |
key=${line%%=*} | |
value=${line#*=} | |
export $key=$value | |
done < $name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment