fix(docker): support bash v3 in macos

This commit is contained in:
David Chan 2026-01-29 23:44:43 +07:00 committed by David Chan
parent 4de0bae45a
commit 3dbfc7b165

View File

@ -129,7 +129,7 @@ upsert_env() {
local -a keys=("$@") local -a keys=("$@")
local tmp local tmp
tmp="$(mktemp)" tmp="$(mktemp)"
declare -A seen=() local seen_keys=""
if [[ -f "$file" ]]; then if [[ -f "$file" ]]; then
while IFS= read -r line || [[ -n "$line" ]]; do while IFS= read -r line || [[ -n "$line" ]]; do
@ -138,7 +138,7 @@ upsert_env() {
for k in "${keys[@]}"; do for k in "${keys[@]}"; do
if [[ "$key" == "$k" ]]; then if [[ "$key" == "$k" ]]; then
printf '%s=%s\n' "$k" "${!k-}" >>"$tmp" printf '%s=%s\n' "$k" "${!k-}" >>"$tmp"
seen["$k"]=1 seen_keys+="|$k|"
replaced=true replaced=true
break break
fi fi
@ -150,7 +150,7 @@ upsert_env() {
fi fi
for k in "${keys[@]}"; do for k in "${keys[@]}"; do
if [[ -z "${seen[$k]:-}" ]]; then if [[ "$seen_keys" != *"|$k|"* ]]; then
printf '%s=%s\n' "$k" "${!k-}" >>"$tmp" printf '%s=%s\n' "$k" "${!k-}" >>"$tmp"
fi fi
done done