fix: guard empty array iteration for bash 3.2 compatibility

The _load_repo_dotenv_preserving_env() function iterates over
${preserved[@]} with set -euo pipefail. On bash 3.2 (macOS default),
an empty array triggers 'unbound variable' under set -u, crashing
ctl.sh start. Bash 4+ handles this fine, but macOS ships 3.2.

Wraps the for loop in a length check: [[ ${#preserved[@]} -gt 0 ]]
This commit is contained in:
Ayush Sahay Chaudhary committed 2026-05-12 10:34:02 +05:30
1 parent 306dd2bf09
commit 74926090e3
1 file changed
+5 -3
+5 -3
View File
@@ -51,9 +51,11 @@ _load_repo_dotenv_preserving_env() {
set +a
local assignment
for assignment in "${preserved[@]}"; do
export "${assignment}"
done
if [[ ${#preserved[@]} -gt 0 ]]; then
for assignment in "${preserved[@]}"; do
export "${assignment}"
done
fi
}
_find_python() {