Last active
June 6, 2019 22:17
-
-
Save felipecwb/1798d426a4d043579da85d91d2cca05e to your computer and use it in GitHub Desktop.
Load dotenv in shell script
This file contains hidden or 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
load_env() { | |
if [ ! -f $1 ]; then | |
return 1 | |
fi | |
echo "> Loading $2 dotenv: $1" | |
awk '!/^#/{if ($1 != "") {print ">> " $0}}' $1 | |
source <(awk '!/^#/{if ($1 != "") {print "export " $0}}' $1) | |
} | |
load_env .env |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment