Created
January 15, 2026 20:13
-
-
Save mahdilamb/577c4b61d35cdb46a84c82054acc6c91 to your computer and use it in GitHub Desktop.
Export specific values
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
| #!/usr/bin/env bash | |
| ALLOWED_VALUES=("$@") | |
| while IFS='=' read -r key value; do | |
| [[ -z "$key" || "$key" =~ ^# ]] && { echo "$key"; continue; } | |
| if [ "${#ALLOWED_VALUES[@]}" -eq 0 ]; then | |
| echo "$key=$value" | |
| continue | |
| fi | |
| for allowed in "${ALLOWED_VALUES[@]}"; do | |
| if [[ "$key" == *"$allowed"* ]]; then | |
| echo "$key=$value" | |
| continue 2 | |
| fi | |
| done | |
| echo "$key=" | |
| done < .env |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment