public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Rasmus Villemoes <ravi@prevas.dk>
To: Francesco Dolcini <francesco@dolcini.it>
Cc: Tom Rini <trini@konsulko.com>,
	 Franz Schnyder <fra.schnyder@gmail.com>, <u-boot@lists.denx.de>,
	 Francesco Dolcini <francesco.dolcini@toradex.com>,
	 Franz Schnyder <franz.schnyder@toradex.com>
Subject: Re: [PATCH] board: toradex: Quote variables in `test` cmd expression
Date: Thu, 09 Apr 2026 11:07:31 +0200	[thread overview]
Message-ID: <87v7e0o624.fsf@prevas.dk> (raw)
In-Reply-To: <ac-ADDwtwS-xuFTE@livingston.pivistrello.it> (Francesco Dolcini's message of "Fri, 3 Apr 2026 10:53:32 +0200")

On Fri, Apr 03 2026, Francesco Dolcini <francesco@dolcini.it> wrote:

> On Thu, Apr 02, 2026 at 05:30:29PM -0600, Tom Rini wrote:
>> On Wed, Apr 01, 2026 at 07:10:27AM +0200, Francesco Dolcini wrote:
>> > On Tue, Mar 31, 2026 at 10:10:10AM +0200, Franz Schnyder wrote:
>> > > From: Franz Schnyder <franz.schnyder@toradex.com>
>> > > 
>> > > 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 8b0619579b22 ("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>
>> 
>> I've decided to go with:
>> https://patchwork.ozlabs.org/project/uboot/patch/20260330140106.401876-1-ravi@prevas.dk/
>> to make sure that everyone that might hit this problem doesn't end up
>> broken, thanks.
>
> I am wondering if you should apply this in any case. This change is generally correct.

I agree. And note that this really isn't anything to do with the 'test'
command per se, it's simply that using any variable whose value can be
empty or contain spaces is prone to produce something other than exactly
1 word, exactly as in userspace shell, and once the shell has done its
parsing and word splitting, the called command really has no way of
knowing that there's an empty argument missing.

> In the past when trying to move to some more modern shell as default stuff broke
> for us, we reverted the change without investigating. Maybe it was exactly the
> same issue.
>
> See https://lore.kernel.org/u-boot/20240111170418.GA7220@francesco-nb/

I don't think that was the same issue, but there are certainly differences
between the old and new parser when it comes to quoting and escaping,
and that 'env set set_apply_overlays ...' line looks quite prone to
being interpreted differently.

Rasmus

      reply	other threads:[~2026-04-09  9:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-31  8:10 [PATCH] board: toradex: Quote variables in `test` cmd expression Franz Schnyder
2026-04-01  5:10 ` Francesco Dolcini
2026-04-02 23:30   ` Tom Rini
2026-04-03  8:53     ` Francesco Dolcini
2026-04-09  9:07       ` Rasmus Villemoes [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v7e0o624.fsf@prevas.dk \
    --to=ravi@prevas.dk \
    --cc=fra.schnyder@gmail.com \
    --cc=francesco.dolcini@toradex.com \
    --cc=francesco@dolcini.it \
    --cc=franz.schnyder@toradex.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox