From 92c08c0d6bfcb4d4ad670104c448c79472a5bba3 Mon Sep 17 00:00:00 2001 From: Daniel Pupius Date: Fri, 2 May 2025 15:43:57 -0700 Subject: [PATCH] Hack for handling env with spaces --- scripts/push-to-ecr.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/push-to-ecr.sh b/scripts/push-to-ecr.sh index 095474d..a291d48 100755 --- a/scripts/push-to-ecr.sh +++ b/scripts/push-to-ecr.sh @@ -4,7 +4,17 @@ set -e # Load environment variables from .env file if [ -f .env ]; then echo "Loading environment variables from .env file" - export $(grep -v '^#' .env | xargs) + # Read .env file line by line to properly handle spaces in values + while IFS='=' read -r key value || [ -n "$key" ]; do + # Skip comments and empty lines + [[ $key =~ ^#.*$ || -z $key ]] && continue + # Remove leading/trailing whitespace + key=$(echo "$key" | xargs) + # Remove quotes from the value if present + value=$(echo "$value" | sed -E 's/^"(.*)"$/\1/' | sed -E "s/^'(.*)'$/\1/") + # Export the variable preserving spaces in the value + export "$key=$value" + done < .env else echo "Warning: .env file not found. Using default environment variables." fi