Skip to content

Commit 3c6d61c

Browse files
authored
Merge pull request #948 from Gavinok/fix-env-precedence
Fix env precedence
2 parents 9fd5cbf + 8096567 commit 3c6d61c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

docker/manage

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,17 @@ configureEnvironment() {
156156
if [ -f .env ]; then
157157
while read line; do
158158
if [[ ! "$line" =~ ^\# ]] && [[ "$line" =~ .*= ]]; then
159-
export "${line//[$'\r\n']}"
159+
var_name="${line%%=*}"
160+
# Strip whitespace from variable name
161+
var_name="${var_name//[[:space:]]/}"
162+
# Only export if not already set (respects command-line precedence)
163+
# Using -v to distinguish between unset and empty variables
164+
if [ ! -v "${var_name}" ]; then
165+
if ! export "${line//[$'\r\n']}" 2>/dev/null; then
166+
echoError "ERROR: Invalid .env line: ${line}"
167+
exit 1
168+
fi
169+
fi
160170
fi
161171
done <.env
162172
fi

0 commit comments

Comments
 (0)