* [PATCH 0/6] test: Quote variables in 'test -n' expressions across boards
@ 2026-05-03 20:49 Simon Glass
2026-05-03 20:49 ` [PATCH 1/6] toradex: Quote fdtfile in preboot test Simon Glass
` (6 more replies)
0 siblings, 7 replies; 12+ messages in thread
From: Simon Glass @ 2026-05-03 20:49 UTC (permalink / raw)
To: u-boot
Cc: Simon Glass, Alice Guo, Andrew Davis, Anshul Dalal,
Bryan Brattlof, Cyril Jean, Emanuele Ghidoli, Enrico Leto,
Ernest Van Hoecke, Fabio Estevam, Francesco Dolcini,
Franz Schnyder, Heiko Schocher, Hiago De Franco, Jaehoon Chung,
Jamie Gibbons, Leo Yu-Chi Liang, Lukasz Majewski, Marek Vasut,
Max Krummenacher, Parth Pancholi, Peng Fan, Rasmus Villemoes,
Sam Protsenko, Siddharth Vadapalli, Tom Rini, Udit Kumar,
Łukasz Majewski
Several boards use 'test -n ${var}' (unquoted) in env scripts to
detect an empty variable and trigger a fallback or skip a hook. That
works only because of a U-Boot 'test' quirk where calls with argc <
3 returned false; an empty variable made the expression 'test -n'
(one operand) and hit that path.
8b0619579b22 ("cmd: test: fix handling of single-argument form of
test") aligned 'test' with POSIX so those expressions flipped to
true. f7e7c55e53e8 ("cmd: test: add bug-compatibility special case
for 'test -n'") restored the old behaviour for the exact 'test -n'
(one arg) case, so the boards are not broken at runtime today, but
the reliance on a bug-compat path isn't great.
This series updates various boards to quote each affected variable so
the emptiness check is explicit and does not depend on the
special-case path.
Each commit carries a Fixes: tag pointing at 8b0619579b22
Simon Glass (6):
toradex: Quote fdtfile in preboot test
ti: Quote board_init in ti_common.env
siemens: Quote A/B flags in env tests
beaglev_fire: Quote no_of_overlays in design test
mccmon6: Quote recovery_status in bootcmd test
aristainetos2: Quote rescue_reason in rescueboot test
configs/apalis-imx8_defconfig | 2 +-
configs/apalis_imx6_defconfig | 2 +-
configs/colibri-imx6ull-emmc_defconfig | 2 +-
configs/colibri-imx6ull_defconfig | 2 +-
configs/colibri-imx8x_defconfig | 2 +-
configs/colibri_imx6_defconfig | 2 +-
configs/colibri_imx7_defconfig | 2 +-
configs/colibri_imx7_emmc_defconfig | 2 +-
configs/colibri_vf_defconfig | 2 +-
configs/toradex-smarc-imx8mp_defconfig | 2 +-
configs/toradex-smarc-imx95_defconfig | 2 +-
configs/verdin-am62_a53_defconfig | 2 +-
configs/verdin-am62p_a53_defconfig | 2 +-
configs/verdin-imx8mm_defconfig | 2 +-
configs/verdin-imx8mp_defconfig | 2 +-
include/configs/aristainetos2.h | 2 +-
include/configs/beaglev_fire.h | 2 +-
include/configs/draco-etamin.h | 4 ++--
include/configs/mccmon6.h | 2 +-
include/configs/siemens-am33x-common.h | 12 ++++++------
include/configs/siemens-env-common.h | 8 ++++----
include/env/ti/ti_common.env | 2 +-
22 files changed, 31 insertions(+), 31 deletions(-)
---
base-commit: bb0f3eebb3c196d9b6efbbd1e5aa9b16abbb9ad6
branch: env-test-us
--
2.43.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/6] toradex: Quote fdtfile in preboot test
2026-05-03 20:49 [PATCH 0/6] test: Quote variables in 'test -n' expressions across boards Simon Glass
@ 2026-05-03 20:49 ` Simon Glass
2026-05-04 4:54 ` Francesco Dolcini
2026-05-03 20:49 ` [PATCH 2/6] ti: Quote board_init in ti_common.env Simon Glass
` (5 subsequent siblings)
6 siblings, 1 reply; 12+ messages in thread
From: Simon Glass @ 2026-05-03 20:49 UTC (permalink / raw)
To: u-boot
Cc: Simon Glass, Alice Guo, Andrew Davis, Anshul Dalal,
Bryan Brattlof, Emanuele Ghidoli, Ernest Van Hoecke,
Fabio Estevam, Francesco Dolcini, Franz Schnyder, Hiago De Franco,
Jaehoon Chung, Marek Vasut, Max Krummenacher, Parth Pancholi,
Peng Fan, Rasmus Villemoes, Sam Protsenko, Tom Rini, Udit Kumar
The 15 Toradex defconfigs (apalis-imx8, apalis_imx6, the colibri
imx6/imx6ull/imx7/imx8x/vf families, the toradex-smarc-imx8mp/imx95
boards and the verdin am62/am62p/imx8mm/imx8mp boards) all carry the
same preboot expression:
test -n ${fdtfile} || setenv fdtfile ...
When fdtfile is empty, the unquoted variable expands to nothing and
the command becomes 'test -n' with no operand, relying on a U-Boot
'test' quirk that treats a missing operand as false so the '||'
fallback runs and sets the DTB name.
Quote the variable so an empty fdtfile expands to 'test -n ""' (two
operands, three argv) and the emptiness check is explicit.
Fixes: 8b0619579b22 ("cmd: test: fix handling of single-argument form of test")
Signed-off-by: Simon Glass <sjg@chromium.org>
---
configs/apalis-imx8_defconfig | 2 +-
configs/apalis_imx6_defconfig | 2 +-
configs/colibri-imx6ull-emmc_defconfig | 2 +-
configs/colibri-imx6ull_defconfig | 2 +-
configs/colibri-imx8x_defconfig | 2 +-
configs/colibri_imx6_defconfig | 2 +-
configs/colibri_imx7_defconfig | 2 +-
configs/colibri_imx7_emmc_defconfig | 2 +-
configs/colibri_vf_defconfig | 2 +-
configs/toradex-smarc-imx8mp_defconfig | 2 +-
configs/toradex-smarc-imx95_defconfig | 2 +-
configs/verdin-am62_a53_defconfig | 2 +-
configs/verdin-am62p_a53_defconfig | 2 +-
configs/verdin-imx8mm_defconfig | 2 +-
configs/verdin-imx8mp_defconfig | 2 +-
15 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/configs/apalis-imx8_defconfig b/configs/apalis-imx8_defconfig
index 6ab4dd3dc57..17090ac682b 100644
--- a/configs/apalis-imx8_defconfig
+++ b/configs/apalis-imx8_defconfig
@@ -25,7 +25,7 @@ CONFIG_DISTRO_DEFAULTS=y
CONFIG_BOOTDELAY=1
CONFIG_OF_SYSTEM_SETUP=y
CONFIG_USE_PREBOOT=y
-CONFIG_PREBOOT="test -n ${fdtfile} || setenv fdtfile ${soc}-apalis${variant}-${fdt_board}.dtb"
+CONFIG_PREBOOT="test -n \"${fdtfile}\" || setenv fdtfile ${soc}-apalis${variant}-${fdt_board}.dtb"
CONFIG_SYS_CBSIZE=2048
CONFIG_SYS_PBSIZE=2068
CONFIG_LOG=y
diff --git a/configs/apalis_imx6_defconfig b/configs/apalis_imx6_defconfig
index cd9811aca61..791be4df283 100644
--- a/configs/apalis_imx6_defconfig
+++ b/configs/apalis_imx6_defconfig
@@ -31,7 +31,7 @@ CONFIG_DISTRO_DEFAULTS=y
CONFIG_BOOTDELAY=1
CONFIG_BOOTCOMMAND="run distro_bootcmd; usb start; setenv stdout serial,vidconsole; setenv stdin serial,usbkbd"
CONFIG_USE_PREBOOT=y
-CONFIG_PREBOOT="test -n ${fdtfile} || setenv fdtfile imx6q-apalis${variant}-${fdt_board}.dtb"
+CONFIG_PREBOOT="test -n \"${fdtfile}\" || setenv fdtfile imx6q-apalis${variant}-${fdt_board}.dtb"
CONFIG_SYS_CBSIZE=1024
CONFIG_SYS_PBSIZE=1055
CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
diff --git a/configs/colibri-imx6ull-emmc_defconfig b/configs/colibri-imx6ull-emmc_defconfig
index 439ddeb8f0b..c54ff48fdf7 100644
--- a/configs/colibri-imx6ull-emmc_defconfig
+++ b/configs/colibri-imx6ull-emmc_defconfig
@@ -18,7 +18,7 @@ CONFIG_FIT_VERBOSE=y
CONFIG_DISTRO_DEFAULTS=y
CONFIG_BOOTDELAY=1
CONFIG_USE_PREBOOT=y
-CONFIG_PREBOOT="test -n ${fdtfile} || setenv fdtfile imx6ull-colibri${variant}-${fdt_board}.dtb"
+CONFIG_PREBOOT="test -n \"${fdtfile}\" || setenv fdtfile imx6ull-colibri${variant}-${fdt_board}.dtb"
CONFIG_SYS_PBSIZE=547
CONFIG_SYS_CONSOLE_IS_IN_ENV=y
# CONFIG_DISPLAY_BOARDINFO is not set
diff --git a/configs/colibri-imx6ull_defconfig b/configs/colibri-imx6ull_defconfig
index 1c400f9534d..cda7a6ada3a 100644
--- a/configs/colibri-imx6ull_defconfig
+++ b/configs/colibri-imx6ull_defconfig
@@ -21,7 +21,7 @@ CONFIG_BOOTDELAY=1
CONFIG_OF_ENV_SETUP=y
CONFIG_BOOTCOMMAND="run ubiboot || run distro_bootcmd;"
CONFIG_USE_PREBOOT=y
-CONFIG_PREBOOT="test -n ${fdtfile} || setenv fdtfile imx6ull-colibri${variant}-${fdt_board}.dtb"
+CONFIG_PREBOOT="test -n \"${fdtfile}\" || setenv fdtfile imx6ull-colibri${variant}-${fdt_board}.dtb"
CONFIG_SYS_PBSIZE=547
CONFIG_SYS_CONSOLE_IS_IN_ENV=y
# CONFIG_DISPLAY_BOARDINFO is not set
diff --git a/configs/colibri-imx8x_defconfig b/configs/colibri-imx8x_defconfig
index fd6a6b47fcf..3300922b172 100644
--- a/configs/colibri-imx8x_defconfig
+++ b/configs/colibri-imx8x_defconfig
@@ -26,7 +26,7 @@ CONFIG_DISTRO_DEFAULTS=y
CONFIG_BOOTDELAY=1
CONFIG_OF_SYSTEM_SETUP=y
CONFIG_USE_PREBOOT=y
-CONFIG_PREBOOT="test -n ${fdtfile} || setenv fdtfile ${soc}-colibri-${fdt_board}.dtb"
+CONFIG_PREBOOT="test -n \"${fdtfile}\" || setenv fdtfile ${soc}-colibri-${fdt_board}.dtb"
CONFIG_SYS_CBSIZE=2048
CONFIG_SYS_PBSIZE=2068
CONFIG_LOG=y
diff --git a/configs/colibri_imx6_defconfig b/configs/colibri_imx6_defconfig
index 0f5abb51f76..34037e1c134 100644
--- a/configs/colibri_imx6_defconfig
+++ b/configs/colibri_imx6_defconfig
@@ -30,7 +30,7 @@ CONFIG_DISTRO_DEFAULTS=y
CONFIG_BOOTDELAY=1
CONFIG_BOOTCOMMAND="run distro_bootcmd; usb start; setenv stdout serial,vidconsole; setenv stdin serial,usbkbd"
CONFIG_USE_PREBOOT=y
-CONFIG_PREBOOT="test -n ${fdtfile} || setenv fdtfile imx6dl-colibri${variant}-${fdt_board}.dtb"
+CONFIG_PREBOOT="test -n \"${fdtfile}\" || setenv fdtfile imx6dl-colibri${variant}-${fdt_board}.dtb"
CONFIG_SYS_CBSIZE=1024
CONFIG_SYS_PBSIZE=1056
CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
diff --git a/configs/colibri_imx7_defconfig b/configs/colibri_imx7_defconfig
index 2a3cb84c3b6..8a84f49f42f 100644
--- a/configs/colibri_imx7_defconfig
+++ b/configs/colibri_imx7_defconfig
@@ -22,7 +22,7 @@ CONFIG_BOOTDELAY=1
CONFIG_OF_ENV_SETUP=y
CONFIG_BOOTCOMMAND="run ubiboot ; echo ; echo ubiboot failed ; run distro_bootcmd;"
CONFIG_USE_PREBOOT=y
-CONFIG_PREBOOT="test -n ${fdtfile} || setenv fdtfile ${soc}-colibri${variant}-${fdt_board}.dtb "
+CONFIG_PREBOOT="test -n \"${fdtfile}\" || setenv fdtfile ${soc}-colibri${variant}-${fdt_board}.dtb "
CONFIG_SYS_PBSIZE=544
CONFIG_SYS_CONSOLE_IS_IN_ENV=y
# CONFIG_DISPLAY_BOARDINFO is not set
diff --git a/configs/colibri_imx7_emmc_defconfig b/configs/colibri_imx7_emmc_defconfig
index a95a3214d0c..4c661d4cda1 100644
--- a/configs/colibri_imx7_emmc_defconfig
+++ b/configs/colibri_imx7_emmc_defconfig
@@ -19,7 +19,7 @@ CONFIG_FIT_VERBOSE=y
CONFIG_DISTRO_DEFAULTS=y
CONFIG_BOOTDELAY=1
CONFIG_USE_PREBOOT=y
-CONFIG_PREBOOT="test -n ${fdtfile} || setenv fdtfile ${soc}-colibri${variant}-${fdt_board}.dtb"
+CONFIG_PREBOOT="test -n \"${fdtfile}\" || setenv fdtfile ${soc}-colibri${variant}-${fdt_board}.dtb"
CONFIG_SYS_PBSIZE=544
CONFIG_SYS_CONSOLE_IS_IN_ENV=y
# CONFIG_DISPLAY_BOARDINFO is not set
diff --git a/configs/colibri_vf_defconfig b/configs/colibri_vf_defconfig
index 1364fe45291..4ce14baef4f 100644
--- a/configs/colibri_vf_defconfig
+++ b/configs/colibri_vf_defconfig
@@ -23,7 +23,7 @@ CONFIG_FDT_FIXUP_PARTITIONS=y
CONFIG_USE_BOOTCOMMAND=y
CONFIG_BOOTCOMMAND="run ubiboot || run distro_bootcmd;"
CONFIG_USE_PREBOOT=y
-CONFIG_PREBOOT="test -n ${fdtfile} || setenv fdtfile ${soc}-colibri-${fdt_board}.dtb"
+CONFIG_PREBOOT="test -n \"${fdtfile}\" || setenv fdtfile ${soc}-colibri-${fdt_board}.dtb"
CONFIG_SYS_PBSIZE=1056
CONFIG_LOGLEVEL=3
# CONFIG_DISPLAY_BOARDINFO is not set
diff --git a/configs/toradex-smarc-imx8mp_defconfig b/configs/toradex-smarc-imx8mp_defconfig
index 13a0e5f028b..7be67df3130 100644
--- a/configs/toradex-smarc-imx8mp_defconfig
+++ b/configs/toradex-smarc-imx8mp_defconfig
@@ -40,7 +40,7 @@ CONFIG_BOOTDELAY=1
CONFIG_OF_SYSTEM_SETUP=y
CONFIG_BOOTCOMMAND="bootflow scan -b"
CONFIG_USE_PREBOOT=y
-CONFIG_PREBOOT="test -n ${fdtfile} || setenv fdtfile imx8mp-toradex-smarc-dev.dtb"
+CONFIG_PREBOOT="test -n \"${fdtfile}\" || setenv fdtfile imx8mp-toradex-smarc-dev.dtb"
CONFIG_SYS_CBSIZE=2048
CONFIG_SYS_PBSIZE=2081
CONFIG_LOG=y
diff --git a/configs/toradex-smarc-imx95_defconfig b/configs/toradex-smarc-imx95_defconfig
index 61abeff1afb..144d8501ce7 100644
--- a/configs/toradex-smarc-imx95_defconfig
+++ b/configs/toradex-smarc-imx95_defconfig
@@ -37,7 +37,7 @@ CONFIG_BOOTDELAY=1
CONFIG_OF_SYSTEM_SETUP=y
CONFIG_BOOTCOMMAND="bootflow scan -b"
CONFIG_USE_PREBOOT=y
-CONFIG_PREBOOT="test -n ${fdtfile} || setenv fdtfile imx95-toradex-smarc-${fdt_board}.dtb"
+CONFIG_PREBOOT="test -n \"${fdtfile}\" || setenv fdtfile imx95-toradex-smarc-${fdt_board}.dtb"
CONFIG_SYS_CBSIZE=2048
CONFIG_SYS_PBSIZE=2074
CONFIG_LOG=y
diff --git a/configs/verdin-am62_a53_defconfig b/configs/verdin-am62_a53_defconfig
index f04858099da..3f3cd2a53b1 100644
--- a/configs/verdin-am62_a53_defconfig
+++ b/configs/verdin-am62_a53_defconfig
@@ -34,7 +34,7 @@ CONFIG_FIT_VERBOSE=y
CONFIG_DISTRO_DEFAULTS=y
CONFIG_BOOTDELAY=1
CONFIG_USE_PREBOOT=y
-CONFIG_PREBOOT="test -n ${fdtfile} || setenv fdtfile k3-am625-verdin-${variant}-${fdt_board}.dtb"
+CONFIG_PREBOOT="test -n \"${fdtfile}\" || setenv fdtfile k3-am625-verdin-${variant}-${fdt_board}.dtb"
CONFIG_LOG=y
# CONFIG_DISPLAY_BOARDINFO is not set
CONFIG_DISPLAY_BOARDINFO_LATE=y
diff --git a/configs/verdin-am62p_a53_defconfig b/configs/verdin-am62p_a53_defconfig
index 3dbffa78662..6cca7427485 100644
--- a/configs/verdin-am62p_a53_defconfig
+++ b/configs/verdin-am62p_a53_defconfig
@@ -36,7 +36,7 @@ CONFIG_BOOTDELAY=1
CONFIG_OF_BOARD_SETUP_EXTENDED=y
CONFIG_BOOTCOMMAND="bootflow scan -b"
CONFIG_USE_PREBOOT=y
-CONFIG_PREBOOT="test -n ${fdtfile} || setenv fdtfile k3-am62p5-verdin-${variant}-${fdt_board}.dtb"
+CONFIG_PREBOOT="test -n \"${fdtfile}\" || setenv fdtfile k3-am62p5-verdin-${variant}-${fdt_board}.dtb"
CONFIG_LOG=y
# CONFIG_DISPLAY_BOARDINFO is not set
CONFIG_DISPLAY_BOARDINFO_LATE=y
diff --git a/configs/verdin-imx8mm_defconfig b/configs/verdin-imx8mm_defconfig
index 45437205837..88f337bd347 100644
--- a/configs/verdin-imx8mm_defconfig
+++ b/configs/verdin-imx8mm_defconfig
@@ -33,7 +33,7 @@ CONFIG_DISTRO_DEFAULTS=y
CONFIG_BOOTDELAY=1
CONFIG_OF_SYSTEM_SETUP=y
CONFIG_USE_PREBOOT=y
-CONFIG_PREBOOT="test -n ${fdtfile} || setenv fdtfile imx8mm-verdin-${variant}-${fdt_board}.dtb"
+CONFIG_PREBOOT="test -n \"${fdtfile}\" || setenv fdtfile imx8mm-verdin-${variant}-${fdt_board}.dtb"
CONFIG_SYS_CBSIZE=2048
CONFIG_SYS_PBSIZE=2081
CONFIG_LOG=y
diff --git a/configs/verdin-imx8mp_defconfig b/configs/verdin-imx8mp_defconfig
index 455a601b07d..368bd4aeeeb 100644
--- a/configs/verdin-imx8mp_defconfig
+++ b/configs/verdin-imx8mp_defconfig
@@ -38,7 +38,7 @@ CONFIG_DISTRO_DEFAULTS=y
CONFIG_BOOTDELAY=1
CONFIG_OF_SYSTEM_SETUP=y
CONFIG_USE_PREBOOT=y
-CONFIG_PREBOOT="test -n ${fdtfile} || setenv fdtfile imx8mp-verdin-${variant}-${fdt_board}.dtb"
+CONFIG_PREBOOT="test -n \"${fdtfile}\" || setenv fdtfile imx8mp-verdin-${variant}-${fdt_board}.dtb"
CONFIG_SYS_CBSIZE=2048
CONFIG_SYS_PBSIZE=2081
CONFIG_LOG=y
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/6] ti: Quote board_init in ti_common.env
2026-05-03 20:49 [PATCH 0/6] test: Quote variables in 'test -n' expressions across boards Simon Glass
2026-05-03 20:49 ` [PATCH 1/6] toradex: Quote fdtfile in preboot test Simon Glass
@ 2026-05-03 20:49 ` Simon Glass
2026-05-03 20:49 ` [PATCH 3/6] siemens: Quote A/B flags in env tests Simon Glass
` (4 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2026-05-03 20:49 UTC (permalink / raw)
To: u-boot
Cc: Simon Glass, Anshul Dalal, Bryan Brattlof, Rasmus Villemoes,
Siddharth Vadapalli, Tom Rini
bootcmd_ti_mmc skips a per-board init hook with:
if test -n ${board_init}; then run board_init; fi;
The default case is "no board override", i.e. board_init unset. The
expression then expands to 'test -n' with no operand and relies on a
U-Boot 'test' quirk that treats a missing operand as false to skip the
run.
Quote the variable so an unset board_init expands to 'test -n ""' and
the emptiness check is explicit.
Fixes: 8b0619579b22 ("cmd: test: fix handling of single-argument form of test")
Signed-off-by: Simon Glass <sjg@chromium.org>
---
include/env/ti/ti_common.env | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/env/ti/ti_common.env b/include/env/ti/ti_common.env
index 62b93eb25c4..e6ceaa17adc 100644
--- a/include/env/ti/ti_common.env
+++ b/include/env/ti/ti_common.env
@@ -24,7 +24,7 @@ get_fit_config=setexpr name_fit_config gsub / _ conf-${fdtfile}
run_fit=run get_fit_config; bootm ${addr_fit}#${name_fit_config}${overlaystring}
bootcmd_ti_mmc=
run init_${boot};
- if test -n ${board_init}; then
+ if test -n "${board_init}"; then
echo Running board_init ...;
run board_init;
fi;
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/6] siemens: Quote A/B flags in env tests
2026-05-03 20:49 [PATCH 0/6] test: Quote variables in 'test -n' expressions across boards Simon Glass
2026-05-03 20:49 ` [PATCH 1/6] toradex: Quote fdtfile in preboot test Simon Glass
2026-05-03 20:49 ` [PATCH 2/6] ti: Quote board_init in ti_common.env Simon Glass
@ 2026-05-03 20:49 ` Simon Glass
2026-05-03 20:49 ` [PATCH 4/6] beaglev_fire: Quote no_of_overlays in design test Simon Glass
` (3 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2026-05-03 20:49 UTC (permalink / raw)
To: u-boot; +Cc: Simon Glass, Enrico Leto, Rasmus Villemoes, Tom Rini
The Siemens am33x-common, env-common and draco-etamin headers gate
boot-partition selection logic on:
if test -n ${A}; then ...
if test -n ${B}; then ...
A and B are flags that the upgrade machinery sets to mark "the other
partition just became active". The default state is unset, in which
case the expression expands to 'test -n' with no operand and relies
on a U-Boot 'test' quirk that treats a missing operand as false to
skip the branch.
Quote each variable so an unset A or B expands to 'test -n ""' and
the emptiness check is explicit.
Fixes: 8b0619579b22 ("cmd: test: fix handling of single-argument form of test")
Signed-off-by: Simon Glass <sjg@chromium.org>
---
include/configs/draco-etamin.h | 4 ++--
include/configs/siemens-am33x-common.h | 12 ++++++------
include/configs/siemens-env-common.h | 8 ++++----
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/include/configs/draco-etamin.h b/include/configs/draco-etamin.h
index 6ae85b575b7..b1b403980b1 100644
--- a/include/configs/draco-etamin.h
+++ b/include/configs/draco-etamin.h
@@ -99,10 +99,10 @@
"nand_args=run bootargs_defaults;" \
"mtdparts default;" \
"setenv ${partitionset_active} true;" \
- "if test -n ${A}; then " \
+ "if test -n \"${A}\"; then " \
"setenv nand_active_ubi_vol ${rootfs_name}_a;" \
"fi;" \
- "if test -n ${B}; then " \
+ "if test -n \"${B}\"; then " \
"setenv nand_active_ubi_vol ${rootfs_name}_b;" \
"fi;" \
"setenv nand_root ubi0:${nand_active_ubi_vol} rw " \
diff --git a/include/configs/siemens-am33x-common.h b/include/configs/siemens-am33x-common.h
index a918dc1350c..da822556909 100644
--- a/include/configs/siemens-am33x-common.h
+++ b/include/configs/siemens-am33x-common.h
@@ -104,11 +104,11 @@
"then " \
"setenv upgrade_available 0;" \
"setenv ${partitionset_active} true;" \
- "if test -n ${A}; then " \
+ "if test -n \"${A}\"; then " \
"setenv partitionset_active B; " \
"env delete A; " \
"fi;" \
- "if test -n ${B}; then " \
+ "if test -n \"${B}\"; then " \
"setenv partitionset_active A; " \
"env delete B; " \
"fi;" \
@@ -205,11 +205,11 @@
"nand_args=run bootargs_defaults;" \
"mtdparts default;" \
"setenv ${partitionset_active} true;" \
- "if test -n ${A}; then " \
+ "if test -n \"${A}\"; then " \
"setenv nand_active_ubi_vol ${nand_active_ubi_vol_A};" \
"setenv nand_src_addr ${nand_src_addr_A};" \
"fi;" \
- "if test -n ${B}; then " \
+ "if test -n \"${B}\"; then " \
"setenv nand_active_ubi_vol ${nand_active_ubi_vol_B};" \
"setenv nand_src_addr ${nand_src_addr_B};" \
"fi;" \
@@ -279,10 +279,10 @@
"nand_args=run bootargs_defaults;" \
"mtdparts default;" \
"setenv ${partitionset_active} true;" \
- "if test -n ${A}; then " \
+ "if test -n \"${A}\"; then " \
"setenv nand_active_ubi_vol ${rootfs_name}_a;" \
"fi;" \
- "if test -n ${B}; then " \
+ "if test -n \"${B}\"; then " \
"setenv nand_active_ubi_vol ${rootfs_name}_b;" \
"fi;" \
"setenv nand_root ubi0:${nand_active_ubi_vol} rw " \
diff --git a/include/configs/siemens-env-common.h b/include/configs/siemens-env-common.h
index c028823e1eb..8ced77cc5e2 100644
--- a/include/configs/siemens-env-common.h
+++ b/include/configs/siemens-env-common.h
@@ -81,12 +81,12 @@
*/
#define ENV_FCT_TOGGLE_PARTITION "toggle_partition="\
"setenv ${partitionset_active} true;" \
- "if test -n ${A}; " \
+ "if test -n \"${A}\"; " \
"then " \
"setenv partitionset_active B; " \
"env delete A; " \
"fi;" \
- "if test -n ${B}; "\
+ "if test -n \"${B}\"; "\
"then " \
"setenv partitionset_active A; " \
"env delete B; " \
@@ -103,11 +103,11 @@
*/
#define ENV_EMMC_FCT_SET_ACTIVE_PARTITION "set_partition=" \
"setenv ${partitionset_active} true;" \
- "if test -n ${A}; " \
+ "if test -n \"${A}\"; " \
"then " \
"setenv mmc_part_nr 1;" \
"fi;" \
- "if test -n ${B}; " \
+ "if test -n \"${B}\"; " \
"then " \
"setenv mmc_part_nr 2;" \
"fi;" \
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/6] beaglev_fire: Quote no_of_overlays in design test
2026-05-03 20:49 [PATCH 0/6] test: Quote variables in 'test -n' expressions across boards Simon Glass
` (2 preceding siblings ...)
2026-05-03 20:49 ` [PATCH 3/6] siemens: Quote A/B flags in env tests Simon Glass
@ 2026-05-03 20:49 ` Simon Glass
2026-05-03 20:49 ` [PATCH 5/6] mccmon6: Quote recovery_status in bootcmd test Simon Glass
` (2 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2026-05-03 20:49 UTC (permalink / raw)
To: u-boot
Cc: Simon Glass, Cyril Jean, Jamie Gibbons, Leo Yu-Chi Liang,
Rasmus Villemoes, Tom Rini
On beaglev_fire, design_overlays gates an overlay-application loop
on:
if test -n ${no_of_overlays}; then ...
The default state is "no overlays", i.e. no_of_overlays unset. The
expression then expands to 'test -n' with no operand and relies on a
U-Boot 'test' quirk that treats a missing operand as false to skip
the loop.
Quote the variable so an unset no_of_overlays expands to 'test -n ""'
and the emptiness check is explicit.
Fixes: 8b0619579b22 ("cmd: test: fix handling of single-argument form of test")
Signed-off-by: Simon Glass <sjg@chromium.org>
---
include/configs/beaglev_fire.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/configs/beaglev_fire.h b/include/configs/beaglev_fire.h
index e3ee0f02f2d..8724a71504c 100644
--- a/include/configs/beaglev_fire.h
+++ b/include/configs/beaglev_fire.h
@@ -30,7 +30,7 @@
#define BOOTENV_DESIGN_OVERLAYS \
"design_overlays=" \
- "if test -n ${no_of_overlays}; then " \
+ "if test -n \"${no_of_overlays}\"; then " \
"setenv inc 1; " \
"setenv idx 0; " \
"fdt resize ${dtbo_size}; " \
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 5/6] mccmon6: Quote recovery_status in bootcmd test
2026-05-03 20:49 [PATCH 0/6] test: Quote variables in 'test -n' expressions across boards Simon Glass
` (3 preceding siblings ...)
2026-05-03 20:49 ` [PATCH 4/6] beaglev_fire: Quote no_of_overlays in design test Simon Glass
@ 2026-05-03 20:49 ` Simon Glass
2026-05-04 6:34 ` Łukasz Majewski
2026-05-03 20:49 ` [PATCH 6/6] aristainetos2: Quote rescue_reason in rescueboot test Simon Glass
2026-05-14 23:15 ` (subset) [PATCH 0/6] test: Quote variables in 'test -n' expressions across boards Tom Rini
6 siblings, 1 reply; 12+ messages in thread
From: Simon Glass @ 2026-05-03 20:49 UTC (permalink / raw)
To: u-boot
Cc: Simon Glass, Lukasz Majewski, Rasmus Villemoes, Tom Rini,
Łukasz Majewski
The mccmon6 bootcmd starts with:
if test -n ${recovery_status}; then run boot_recovery; ...
The default state is "no recovery requested", i.e. recovery_status
unset. The expression then expands to 'test -n' with no operand and
relies on a U-Boot 'test' quirk that treats a missing operand as
false to skip recovery.
Quote the variable so an unset recovery_status expands to 'test -n ""'
and the emptiness check is explicit.
Fixes: 8b0619579b22 ("cmd: test: fix handling of single-argument form of test")
Signed-off-by: Simon Glass <sjg@chromium.org>
---
include/configs/mccmon6.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/configs/mccmon6.h b/include/configs/mccmon6.h
index 9f401718bfb..0cf62d6bda8 100644
--- a/include/configs/mccmon6.h
+++ b/include/configs/mccmon6.h
@@ -88,7 +88,7 @@
"bootm $loadaddr};reset;" \
"fi\0" \
"bootcmd=" \
- "if test -n ${recovery_status}; then " \
+ "if test -n \"${recovery_status}\"; then " \
"run boot_recovery;" \
"else " \
"if test ! -n ${boot_medium}; then " \
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 6/6] aristainetos2: Quote rescue_reason in rescueboot test
2026-05-03 20:49 [PATCH 0/6] test: Quote variables in 'test -n' expressions across boards Simon Glass
` (4 preceding siblings ...)
2026-05-03 20:49 ` [PATCH 5/6] mccmon6: Quote recovery_status in bootcmd test Simon Glass
@ 2026-05-03 20:49 ` Simon Glass
2026-05-04 12:54 ` Heiko Schocher
2026-05-14 23:15 ` (subset) [PATCH 0/6] test: Quote variables in 'test -n' expressions across boards Tom Rini
6 siblings, 1 reply; 12+ messages in thread
From: Simon Glass @ 2026-05-03 20:49 UTC (permalink / raw)
To: u-boot; +Cc: Simon Glass, Heiko Schocher, Rasmus Villemoes, Tom Rini
The rescueboot script optionally runs a per-board rescue_reason hook
with:
if test -n ${rescue_reason}; then run rescue_reason; fi;
The default state is "no rescue reason script", i.e. rescue_reason
unset. The expression then expands to 'test -n' with no operand and
relies on a U-Boot 'test' quirk that treats a missing operand as
false to skip the run.
Quote the variable so an unset rescue_reason expands to 'test -n ""'
and the emptiness check is explicit.
Fixes: 8b0619579b22 ("cmd: test: fix handling of single-argument form of test")
Signed-off-by: Simon Glass <sjg@chromium.org>
---
include/configs/aristainetos2.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/configs/aristainetos2.h b/include/configs/aristainetos2.h
index 8a66b1275df..2078ebc5282 100644
--- a/include/configs/aristainetos2.h
+++ b/include/configs/aristainetos2.h
@@ -211,7 +211,7 @@
"${pubkey}\0" \
"rescueboot=echo Booting rescue system ...; " \
"run addmtd addmisc;" \
- "if test -n ${rescue_reason}; then run rescue_reason;fi;" \
+ "if test -n \"${rescue_reason}\"; then run rescue_reason;fi;" \
"run boot_board_type;" \
"if bootm ${fit_addr_r}; then ; " \
"else " \
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/6] toradex: Quote fdtfile in preboot test
2026-05-03 20:49 ` [PATCH 1/6] toradex: Quote fdtfile in preboot test Simon Glass
@ 2026-05-04 4:54 ` Francesco Dolcini
2026-05-04 12:15 ` Simon Glass
0 siblings, 1 reply; 12+ messages in thread
From: Francesco Dolcini @ 2026-05-04 4:54 UTC (permalink / raw)
To: Simon Glass
Cc: u-boot, Alice Guo, Andrew Davis, Anshul Dalal, Bryan Brattlof,
Emanuele Ghidoli, Ernest Van Hoecke, Fabio Estevam,
Francesco Dolcini, Franz Schnyder, Hiago De Franco, Jaehoon Chung,
Marek Vasut, Max Krummenacher, Parth Pancholi, Peng Fan,
Rasmus Villemoes, Sam Protsenko, Tom Rini, Udit Kumar
Hello Simon,
On Sun, May 03, 2026 at 02:49:19PM -0600, Simon Glass wrote:
> The 15 Toradex defconfigs (apalis-imx8, apalis_imx6, the colibri
> imx6/imx6ull/imx7/imx8x/vf families, the toradex-smarc-imx8mp/imx95
> boards and the verdin am62/am62p/imx8mm/imx8mp boards) all carry the
> same preboot expression:
>
> test -n ${fdtfile} || setenv fdtfile ...
Thanks for the patch.
This was already sent weeks ago, see https://lore.kernel.org/all/20260331-fix-test-cmd-empty-v1-1-56cb93fc8f43@toradex.com/
Francesco
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 5/6] mccmon6: Quote recovery_status in bootcmd test
2026-05-03 20:49 ` [PATCH 5/6] mccmon6: Quote recovery_status in bootcmd test Simon Glass
@ 2026-05-04 6:34 ` Łukasz Majewski
0 siblings, 0 replies; 12+ messages in thread
From: Łukasz Majewski @ 2026-05-04 6:34 UTC (permalink / raw)
To: Simon Glass; +Cc: u-boot, Rasmus Villemoes, Tom Rini, Łukasz Majewski
On Sun, 3 May 2026 14:49:23 -0600
Simon Glass <sjg@chromium.org> wrote:
> The mccmon6 bootcmd starts with:
>
> if test -n ${recovery_status}; then run boot_recovery; ...
>
> The default state is "no recovery requested", i.e. recovery_status
> unset. The expression then expands to 'test -n' with no operand and
> relies on a U-Boot 'test' quirk that treats a missing operand as
> false to skip recovery.
>
> Quote the variable so an unset recovery_status expands to 'test -n ""'
> and the emptiness check is explicit.
>
> Fixes: 8b0619579b22 ("cmd: test: fix handling of single-argument form
> of test") Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> include/configs/mccmon6.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/configs/mccmon6.h b/include/configs/mccmon6.h
> index 9f401718bfb..0cf62d6bda8 100644
> --- a/include/configs/mccmon6.h
> +++ b/include/configs/mccmon6.h
> @@ -88,7 +88,7 @@
> "bootm $loadaddr};reset;" \
> "fi\0" \
> "bootcmd=" \
> - "if test -n ${recovery_status}; then " \
> + "if test -n \"${recovery_status}\"; then " \
> "run boot_recovery;" \
> "else " \
> "if test ! -n ${boot_medium}; then " \
Reviewed-by: Łukasz Majewski <lukma@nabladev.com>
--
Best regards,
Lukasz Majewski
--
Nabla Software Engineering GmbH
HRB 40522 Augsburg
Phone: +49 821 45592596
E-Mail: office@nabladev.com
Managing Director : Stefano Babic
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/6] toradex: Quote fdtfile in preboot test
2026-05-04 4:54 ` Francesco Dolcini
@ 2026-05-04 12:15 ` Simon Glass
0 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2026-05-04 12:15 UTC (permalink / raw)
To: Francesco Dolcini
Cc: u-boot, Alice Guo, Andrew Davis, Anshul Dalal, Bryan Brattlof,
Emanuele Ghidoli, Ernest Van Hoecke, Fabio Estevam,
Francesco Dolcini, Franz Schnyder, Hiago De Franco, Jaehoon Chung,
Marek Vasut, Max Krummenacher, Parth Pancholi, Peng Fan,
Rasmus Villemoes, Sam Protsenko, Tom Rini, Udit Kumar
Hi Francesco,
On Sun, 3 May 2026 at 22:54, Francesco Dolcini <francesco@dolcini.it> wrote:
>
> Hello Simon,
>
> On Sun, May 03, 2026 at 02:49:19PM -0600, Simon Glass wrote:
> > The 15 Toradex defconfigs (apalis-imx8, apalis_imx6, the colibri
> > imx6/imx6ull/imx7/imx8x/vf families, the toradex-smarc-imx8mp/imx95
> > boards and the verdin am62/am62p/imx8mm/imx8mp boards) all carry the
> > same preboot expression:
> >
> > test -n ${fdtfile} || setenv fdtfile ...
>
> Thanks for the patch.
>
> This was already sent weeks ago, see https://lore.kernel.org/all/20260331-fix-test-cmd-empty-v1-1-56cb93fc8f43@toradex.com/
>
Thanks, I'll reply on that.
Regards,
Simon
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 6/6] aristainetos2: Quote rescue_reason in rescueboot test
2026-05-03 20:49 ` [PATCH 6/6] aristainetos2: Quote rescue_reason in rescueboot test Simon Glass
@ 2026-05-04 12:54 ` Heiko Schocher
0 siblings, 0 replies; 12+ messages in thread
From: Heiko Schocher @ 2026-05-04 12:54 UTC (permalink / raw)
To: Simon Glass, u-boot; +Cc: Rasmus Villemoes, Tom Rini
Hello Simon,
On 03.05.26 22:49, Simon Glass wrote:
> The rescueboot script optionally runs a per-board rescue_reason hook
> with:
>
> if test -n ${rescue_reason}; then run rescue_reason; fi;
>
> The default state is "no rescue reason script", i.e. rescue_reason
> unset. The expression then expands to 'test -n' with no operand and
> relies on a U-Boot 'test' quirk that treats a missing operand as
> false to skip the run.
>
> Quote the variable so an unset rescue_reason expands to 'test -n ""'
> and the emptiness check is explicit.
>
> Fixes: 8b0619579b22 ("cmd: test: fix handling of single-argument form of test")
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> include/configs/aristainetos2.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Thanks!
Reviewed-by: Heiko Schocher <hs@nabladev.com>
bye,
Heiko
--
Nabla Software Engineering
HRB 40522 Augsburg
Phone: +49 821 45592596
E-Mail: office@nabladev.com
Geschäftsführer : Stefano Babic
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: (subset) [PATCH 0/6] test: Quote variables in 'test -n' expressions across boards
2026-05-03 20:49 [PATCH 0/6] test: Quote variables in 'test -n' expressions across boards Simon Glass
` (5 preceding siblings ...)
2026-05-03 20:49 ` [PATCH 6/6] aristainetos2: Quote rescue_reason in rescueboot test Simon Glass
@ 2026-05-14 23:15 ` Tom Rini
6 siblings, 0 replies; 12+ messages in thread
From: Tom Rini @ 2026-05-14 23:15 UTC (permalink / raw)
To: u-boot, Simon Glass
Cc: Alice Guo, Andrew Davis, Anshul Dalal, Bryan Brattlof, Cyril Jean,
Emanuele Ghidoli, Enrico Leto, Ernest Van Hoecke, Fabio Estevam,
Francesco Dolcini, Franz Schnyder, Heiko Schocher,
Hiago De Franco, Jaehoon Chung, Jamie Gibbons, Leo Yu-Chi Liang,
Lukasz Majewski, Marek Vasut, Max Krummenacher, Parth Pancholi,
Peng Fan, Rasmus Villemoes, Sam Protsenko, Siddharth Vadapalli,
Udit Kumar, Łukasz Majewski
On Sun, 03 May 2026 14:49:18 -0600, Simon Glass wrote:
> Several boards use 'test -n ${var}' (unquoted) in env scripts to
> detect an empty variable and trigger a fallback or skip a hook. That
> works only because of a U-Boot 'test' quirk where calls with argc <
> 3 returned false; an empty variable made the expression 'test -n'
> (one operand) and hit that path.
>
> 8b0619579b22 ("cmd: test: fix handling of single-argument form of
> test") aligned 'test' with POSIX so those expressions flipped to
> true. f7e7c55e53e8 ("cmd: test: add bug-compatibility special case
> for 'test -n'") restored the old behaviour for the exact 'test -n'
> (one arg) case, so the boards are not broken at runtime today, but
> the reliance on a bug-compat path isn't great.
>
> [...]
Applied to u-boot/next, thanks!
[2/6] ti: Quote board_init in ti_common.env
commit: 825f8ee2fcf64ef5875a0bc0a3e2d8650acdc298
[3/6] siemens: Quote A/B flags in env tests
commit: 6b109a1304a03b35ad489e551964737ad80f6a82
[4/6] beaglev_fire: Quote no_of_overlays in design test
commit: 2120834c25d525b754a8473565d4e0f9c158d806
[5/6] mccmon6: Quote recovery_status in bootcmd test
commit: 9458e39c6595e2e00a1d0a645676eaf935e783c7
[6/6] aristainetos2: Quote rescue_reason in rescueboot test
commit: 93d7dc20e80e33ace9b871de44877548642f86cb
--
Tom
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-05-14 23:15 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-03 20:49 [PATCH 0/6] test: Quote variables in 'test -n' expressions across boards Simon Glass
2026-05-03 20:49 ` [PATCH 1/6] toradex: Quote fdtfile in preboot test Simon Glass
2026-05-04 4:54 ` Francesco Dolcini
2026-05-04 12:15 ` Simon Glass
2026-05-03 20:49 ` [PATCH 2/6] ti: Quote board_init in ti_common.env Simon Glass
2026-05-03 20:49 ` [PATCH 3/6] siemens: Quote A/B flags in env tests Simon Glass
2026-05-03 20:49 ` [PATCH 4/6] beaglev_fire: Quote no_of_overlays in design test Simon Glass
2026-05-03 20:49 ` [PATCH 5/6] mccmon6: Quote recovery_status in bootcmd test Simon Glass
2026-05-04 6:34 ` Łukasz Majewski
2026-05-03 20:49 ` [PATCH 6/6] aristainetos2: Quote rescue_reason in rescueboot test Simon Glass
2026-05-04 12:54 ` Heiko Schocher
2026-05-14 23:15 ` (subset) [PATCH 0/6] test: Quote variables in 'test -n' expressions across boards Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox