Skip to content

Fix set -u empty array expansion in 9 scripts#80

Merged
mwunderl merged 1 commit intomainfrom
fix/set-u-array-expansion
Apr 30, 2026
Merged

Fix set -u empty array expansion in 9 scripts#80
mwunderl merged 1 commit intomainfrom
fix/set-u-array-expansion

Conversation

@mwunderl
Copy link
Copy Markdown
Contributor

Under set -u, ${ARRAY[@]} on an empty array triggers unbound variable and exits the script. This causes spurious failures in cleanup functions when no resources were tracked.

Fix: ${ARRAY[@]+"${ARRAY[@]}"} — expands to nothing when the array is empty.

Scripts fixed: 001, 015, 046, 049, 055, 062, 070, 077, 079

Tested locally: 070-dynamodb, 062-support, 077-account-management, 079-iot-device-defender — all pass clean.

Also adds .gitignore for test artifacts (log files, temp keys, JSON outputs).

set -u fix: ${ARRAY[@]} on empty array triggers 'unbound variable'.
Use ${ARRAY[@]+"${ARRAY[@]}"} which expands to nothing when empty.
Scripts: 001, 015, 046, 049, 055, 062, 070, 077, 079.

015-vpc-peering: Replace broken VPC reuse logic with:
- Check VPC quota upfront, fail fast if insufficient
- Use prereq stack VPC if available (saves 1 VPC slot)
- Create fresh VPCs with non-overlapping CIDRs otherwise
- Use .100.0/24 subnets to avoid prereq subnet overlap
Tested both scenarios locally.
@mwunderl mwunderl force-pushed the fix/set-u-array-expansion branch from 47959a2 to 7388f94 Compare April 30, 2026 15:53
@mwunderl mwunderl merged commit 3766e01 into main Apr 30, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant