fix: bash 3.2 compat — sed for pattern sub + split local var=$(cmd) (#1572, #1571) (#1587)

Issue #1572: Replace bash 4+ ${//} pattern substitution in generate_env_config
with sed for macOS bash 3.2 compatibility.

Issue #1571: Split local var=$(cmd) declarations in fly/lib/common.sh so
exit codes propagate correctly with set -e on macOS bash 3.2.

Agent: code-health

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
A 2026-02-21 07:49:17 -08:00 committed by GitHub
parent ce8b1afdf8
commit ed9501235b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View file

@ -685,8 +685,10 @@ except Exception:
# List all Fly.io apps and machines
list_servers() {
local org=$(get_fly_org)
local response=$(fly_api GET "/apps?org_slug=$org")
local org
org=$(get_fly_org)
local response
response=$(fly_api GET "/apps?org_slug=$org")
printf '%s' "$response" | python3 -c "
import json, sys

View file

@ -1278,7 +1278,9 @@ generate_env_config() {
fi
# Escape any single quotes in the value: replace ' with '\''
local escaped_value="${value//\'/\'\\\'\'}"
# Use sed instead of ${//} pattern substitution for bash 3.2 (macOS) compat
local escaped_value
escaped_value=$(printf '%s' "$value" | sed "s/'/'\\\\''/g")
echo "export ${key}='${escaped_value}'"
done
}