fix: handle empty EXTRA_ARGS array in bash 3.2 (macOS default)#289
fix: handle empty EXTRA_ARGS array in bash 3.2 (macOS default)#289gandalf-at-lerian wants to merge 1 commit intomainfrom
Conversation
set -u with empty arrays throws 'unbound variable' on bash < 4.4.
Use the conditional expansion form ${arr[@]+"${arr[@]}"} which
expands to nothing when the array is empty, compatible with all bash versions.
Fixes: https://github.com/LerianStudio/ring/issues (reported by Garzão)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe installation script 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📝 Coding Plan
Comment |
Problem
On macOS, the default bash is 3.2. With
set -u(unbound variable protection), expanding an empty array"${EXTRA_ARGS[@]}"throws:This happens whenever the user answers
Nto all three optional prompts (symlink, verbose, dry-run), leavingEXTRA_ARGSas an empty array.Fix
Use the conditional expansion form
${arr[@]+"${arr[@]}"}— expands to nothing when the array is empty, fully compatible with bash 3.2+.Reported by
Garzão via #the-ring-feedbacks