Skip to content

Instantly share code, notes, and snippets.

@sekia
Last active October 1, 2021 09:32
Show Gist options
  • Save sekia/b12cb31976a5abb779db69f7ff88b8e3 to your computer and use it in GitHub Desktop.
Save sekia/b12cb31976a5abb779db69f7ff88b8e3 to your computer and use it in GitHub Desktop.
dotenv version of env(1)
#!/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