This commit is contained in:
David Chan 2026-01-30 09:04:25 -05:00 committed by GitHub
commit e7c8d6aa1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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