Skip to content

Instantly share code, notes, and snippets.

@Koronen
Last active August 29, 2015 14:13
Show Gist options
  • Save Koronen/140f213d75408adcc639 to your computer and use it in GitHub Desktop.
Save Koronen/140f213d75408adcc639 to your computer and use it in GitHub Desktop.
Add missing keys from .env.sample to .env
#!/usr/bin/env sh
set -e
if [ ! -f .env ]; then
cp .env.sample .env
fi
present_keys=$(grep -v "^#" .env | cut -d= -f1)
missing_keys=$(grep -v "^#" .env.sample | cut -d= -f1 | grep -Fvx "$present_keys" || true)
if [ -n "$missing_keys" ]; then
grep "$missing_keys" .env.sample >> .env
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment