(#9400 P1a) Replace POSIX [ ] with bash [[ ]] across build framework#9462
(#9400 P1a) Replace POSIX [ ] with bash [[ ]] across build framework#9462igorpecovnik merged 15 commits intomainfrom
Conversation
Replace POSIX `[ ]` with bash `[[ ]]` on three remaining single-bracket conditionals: two numeric comparisons on sfdisk version (lines 251, 270) and one -z test with unquoted variable (line 485, also adds quoting). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace POSIX `[ ]` with bash `[[ ]]` on one string comparison. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace POSIX `[ ]` with bash `[[ ]]` on one array expansion check. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…o [[ ]] Replace POSIX `[ ]` with bash `[[ ]]` on six conditionals: file existence checks, string comparisons, and -n tests. Also normalise `=` to `==` in the string comparison. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…[ ]] Replace POSIX `[ ]` with bash `[[ ]]` on four conditionals: file/path existence checks and an array length comparison. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…[ ]] Replace two chained POSIX `[ ]` with a single bash `[[ ]]` using `&&` inside the double brackets. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace POSIX `[ ]` with bash `[[ ]]` on one string comparison. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace POSIX `[ ]` with bash `[[ ]]` on one -n test. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace POSIX `[ ]` with bash `[[ ]]` on one directory existence check. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…[[ ]] Replace POSIX `[ ]` with bash `[[ ]]` on one numeric argument-count check. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace POSIX `[ ]` with bash `[[ ]]` on two file existence checks. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace POSIX `[ ]` with bash `[[ ]]` on two file existence checks. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace POSIX `[ ]` with bash `[[ ]]`; also quote the unquoted `$1` positional parameter inside the file test. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace POSIX `[ ]` with bash `[[ ]]`; also quote the unquoted `${2}boot0`
expansion to prevent word-splitting on the path.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…[[ ]]
Replace all 43 POSIX `[ ]` tests with bash `[[ ]]` across five board-side
package hook functions (preinst, postinst_base, postinst_finish,
postinst_update_uboot_bootscript, get_bootscript_info).
Normalise `=` to `==` in the `"$1" == "upgrade"` comparison.
Collapse paired `[ A ] && [ B ]` into a single `[[ A && B ]]` where possible.
Variables that were previously unquoted inside `[ ]` (e.g. ${BOOTSCRIPT_DST},
${BOOTSCRIPT_BACKUP_VERSION}) are now properly quoted.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (15)
📝 WalkthroughWalkthroughThis PR systematically replaces POSIX-style single-bracket test operators with Bash extended test operators across 15 shell script files, while improving variable quoting and normalizing path concatenation for safer evaluation. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ This PR has been reviewed and approved — all set for merge! |
Summary
Part of #9400 — bash syntax safety improvements.
P1a: Replace POSIX
[ ]with bash[[ ]]across the build framework.Why
[[ ]]is safer than[ ][[ ]]is a bash keyword (not an external command), so unquoted variables inside it do not undergo word-splitting or glob expansion — eliminating a class of subtle bugs&&/||can be used inside[[ ]]instead of chaining separate[ ] && [ ]tests=~) and glob patterns (==with*) are supported natively-ge,-lt, etc.) work identically in both formsChanges
15 files × 1 commit each (per project convention):
lib/functions/image/partitioning.shlib/functions/host/prepare-host.shlib/functions/main/config-prepare.shlib/functions/configuration/main-config.shlib/functions/rootfs/distro-specific.shlib/functions/rootfs/distro-agnostic.sh[ ] && [ ]into one[[ && ]])lib/functions/image/initrd.shlib/functions/image/fingerprint.shlib/functions/bsp/utils-bsp.shlib/functions/compilation/kernel-debs.shextensions/lowmem.shextensions/gxlimg.shconfig/sources/families/rockchip.conf$1)config/sources/families/spacemit.conf${2}boot0)lib/functions/bsp/armbian-bsp-cli-deb.shAdditional fixes bundled where naturally adjacent:
=→==in string comparisons (preferred style in[[ ]])[ A ] && [ B ]collapsed into single[[ A && B ]][ ]tests that were at risk of word-splitting are now quoted🤖 Generated with Claude Code
Summary by CodeRabbit