board: toradex: Quote variables in test cmd expression

With correct POSIX handling, unquoted empty variables can turn the
expression like
	test -n ${fdtfile}
into
	test -n

The POSIX handling for single argument `test` evaluates it as true,
so the fallback initialization will be skipped unexpectedly.
Quoting variable expansions in `test` expressions will always result in
correct behavior for empty and non-empty values.
This change was triggered by
commit 8b0619579b ("cmd: test: fix handling of single-argument form of test")
The aim is to have a less fragile codebase that is not dependent on a
quirk of the shell implementation.

Use quoted variable expansions in `test` expressions throughout.

Signed-off-by: Franz Schnyder <franz.schnyder@toradex.com>
Acked-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Franz Schnyder
2026-03-31 10:10:10 +02:00
committed by Tom Rini
parent bb0f3eebb3
commit 92a04aea6d
20 changed files with 24 additions and 24 deletions

View File

@@ -23,21 +23,21 @@ dfu_alt_info_ram=
update_tiboot3=
askenv confirm Did you load tiboot3.bin (y/N)?;
if test $confirm = y; then
if test "$confirm" = y; then
setexpr blkcnt ${filesize} + 0x1ff && setexpr blkcnt ${blkcnt} / 0x200;
mmc dev 0 1; mmc write ${loadaddr} 0x0 ${blkcnt};
fi
update_tispl=
askenv confirm Did you load tispl.bin (y/N)?;
if test $confirm = y; then
if test "$confirm" = y; then
setexpr blkcnt ${filesize} + 0x1ff && setexpr blkcnt ${blkcnt} / 0x200;
mmc dev 0 1; mmc write ${loadaddr} 0x400 ${blkcnt};
fi
update_uboot=
askenv confirm Did you load u-boot.img (y/N)?;
if test $confirm = y; then
if test "$confirm" = y; then
setexpr blkcnt ${filesize} + 0x1ff && setexpr blkcnt ${blkcnt} / 0x200;
mmc dev 0 1; mmc write ${loadaddr} 0x1400 ${blkcnt};
fi

View File

@@ -13,7 +13,7 @@ scriptaddr=0x50280000
update_uboot=
askenv confirm Did you load flash.bin (y/N)?;
if test $confirm = y; then
if test "$confirm" = y; then
setexpr blkcnt ${filesize} + 0x1ff && setexpr blkcnt
${blkcnt} / 0x200; mmc dev 0 1; mmc write ${loadaddr} 0x0
${blkcnt};

View File

@@ -13,7 +13,7 @@ scriptaddr=0x9c600000
update_uboot=
askenv confirm Did you load flash.bin (y/N)?;
if test $confirm = y; then
if test "$confirm" = y; then
setexpr blkcnt ${filesize} + 0x1ff && setexpr blkcnt
${blkcnt} / 0x200; mmc dev 0 1; mmc write ${loadaddr} 0x0
${blkcnt};

View File

@@ -21,21 +21,21 @@ dfu_alt_info_ram=
update_tiboot3=
askenv confirm Did you load tiboot3.bin (y/N)?;
if test $confirm = y; then
if test "$confirm" = y; then
setexpr blkcnt ${filesize} + 0x1ff && setexpr blkcnt ${blkcnt} / 0x200;
mmc dev 0 1; mmc write ${loadaddr} 0x0 ${blkcnt};
fi
update_tispl=
askenv confirm Did you load tispl.bin (y/N)?;
if test $confirm = y; then
if test "$confirm" = y; then
setexpr blkcnt ${filesize} + 0x1ff && setexpr blkcnt ${blkcnt} / 0x200;
mmc dev 0 1; mmc write ${loadaddr} 0x400 ${blkcnt};
fi
update_uboot=
askenv confirm Did you load u-boot.img (y/N)?;
if test $confirm = y; then
if test "$confirm" = y; then
setexpr blkcnt ${filesize} + 0x1ff && setexpr blkcnt ${blkcnt} / 0x200;
mmc dev 0 1; mmc write ${loadaddr} 0x1400 ${blkcnt};
fi