Last active
October 1, 2021 09:32
-
-
Save sekia/b12cb31976a5abb779db69f7ff88b8e3 to your computer and use it in GitHub Desktop.
dotenv version of env(1)
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/zsh | |
set -e | |
file=$(pwd)/.env | |
if [[ ! -e $file ]]; then | |
echo File not found: $file > /dev/stderr | |
exit 1 | |
fi | |
envs=() | |
while read line; do | |
if [[ "$line" =~ "^[\s\t]*(#|$)" ]]; then | |
continue | |
fi | |
envs+=$line | |
done < $file | |
env $envs $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment