Fix setup.sh crash on Mac with empty gitignore array

The `set -u` (nounset) flag in setup.sh causes `${_HIDDEN_GITIGNORES[@]}`
to fail with "unbound variable" when no parent .gitignore with `*` is
found (common on Mac where the install is not inside a Python venv).

Use the `${arr[@]+"${arr[@]}"}` idiom to safely expand empty arrays
under nounset mode.
This commit is contained in:
Daniel Han 2026-03-16 05:32:20 +00:00
commit 6c2a593522

View file

@ -137,7 +137,7 @@ while [ "$_dir" != "/" ]; do
done
_restore_gitignores() {
for _gi in "${_HIDDEN_GITIGNORES[@]}"; do
for _gi in "${_HIDDEN_GITIGNORES[@]+"${_HIDDEN_GITIGNORES[@]}"}"; do
mv "${_gi}._twbuild" "$_gi" 2>/dev/null || true
done
}