From: Rasmus Villemoes <ravi@prevas.dk>
To: Franz Schnyder <fra.schnyder@gmail.com>
Cc: Tom Rini <trini@konsulko.com>,
u-boot@lists.denx.de, Quentin Schulz <quentin.schulz@cherry.de>,
Francesco Dolcini <francesco@dolcini.it>,
Franz Schnyder <franz.schnyder@toradex.com>
Subject: Re: [PATCH v2 0/4] add [ as alias for test, fix 0/1 argument handling
Date: Fri, 27 Mar 2026 20:38:12 +0100 [thread overview]
Message-ID: <87wlyxjc63.fsf@prevas.dk> (raw)
In-Reply-To: <wkhnll7k5qq5jzjdhspaisvsoygscuhuqaqdz6sahrxwuhihk5@uedggycyvvwl> (Franz Schnyder's message of "Fri, 27 Mar 2026 16:48:52 +0100")
On Fri, Mar 27 2026, Franz Schnyder <fra.schnyder@gmail.com> wrote:
> On Wed, Mar 25, 2026 at 05:05:59PM -0600, Tom Rini wrote:
>> On Thu, 12 Mar 2026 11:01:02 +0100, Rasmus Villemoes wrote:
>>
>> > Make 'test' behave a little more like its cousins in other shells, by
>> > allowing the [ ... ] spelling, and while here, fix up the handling of
>> > a single, non-empty argument to comply with POSIX.
>> >
>> > v2: update documentation, add a few more test cases.
>> >
>> > CI is happy: https://github.com/u-boot/u-boot/pull/905
>> >
>> > [...]
>>
>> Applied to u-boot/next, thanks!
>>
>> [1/4] cmd: test: allow using [ as alias for test
>> commit: fc8bf9a984c118d551b3f93c66f1ae2733b9b588
>> [2/4] doc: test: document [ ] spelling of test
>> commit: d44f61582947564991cce7501f2e5db0b29ebad6
>> [3/4] test: add tests for left-bracket alias for 'test' command
>> commit: 6f9cc3310a764aaae4478b5a8a0c0cae3b2be4a1
>> [4/4] cmd: test: fix handling of single-argument form of test
>> commit: 8b0619579b2282050e7fb0d92fbc645b79d18bae
>> --
>> Tom
>>
>>
> Hello,
>
> While preparing a patch series based on u-boot/next, I realised that
> the bootflow on our module broke.
> I discovered that the issue was introduced with
> commit 8b0619579b2 ("cmd: test: fix handling of single-argument form of test")
>
> This change breaks our boot script as it relies on the behaviour of test
> with unquoted empty expansions. For example:
>
> ```
> test -n ${m4boot} || env set m4boot ';'
> ```
> Is now `test -n`, as there are no quotation marks. It now returns
> true, so the fallback assignment is skipped and it breaks our boot flow.
>
> Any ideas? I think that we will not be the only ones affected by
> this once it's merged into master.
Urrgh, sorry about that. That snippet is arguably fragile and buggy, but
yes, similar code can exist elsewhere.
I don't really like it, but I suppose one could special-case the
single-argument case and interpret
test -n
as
test -n ""
with all other single-argument strings behaving as they do now. This
would need a separate test case and explicit documentation. It's
probably quite rare that one would test a string for emptiness where a
possible non-empty value is exactly "-n", and since the single-argument
case hasn't really been supported in U-Boot until now, I don't think
such code really exists. Moreover, I don't think one should ever rely on
that single-argument behaviour anyway;
test "$str"
should always be spelled
test -n "$str"
Single-argument 'test -z' does not need special treatment, because
both 'test -z' and 'test -z ""' are true, but we could add the former as
a test case as well if we do implement the above.
Rasmus
prev parent reply other threads:[~2026-03-27 19:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 10:01 [PATCH v2 0/4] add [ as alias for test, fix 0/1 argument handling Rasmus Villemoes
2026-03-12 10:01 ` [PATCH v2 1/4] cmd: test: allow using [ as alias for test Rasmus Villemoes
2026-03-12 10:01 ` [PATCH v2 2/4] doc: test: document [ ] spelling of test Rasmus Villemoes
2026-03-12 10:01 ` [PATCH v2 3/4] test: add tests for left-bracket alias for 'test' command Rasmus Villemoes
2026-03-12 10:01 ` [PATCH v2 4/4] cmd: test: fix handling of single-argument form of test Rasmus Villemoes
2026-03-13 6:24 ` [PATCH v2 0/4] add [ as alias for test, fix 0/1 argument handling Anshul Dalal
2026-03-25 23:05 ` Tom Rini
2026-03-27 15:48 ` Franz Schnyder
2026-03-27 19:38 ` 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=87wlyxjc63.fsf@prevas.dk \
--to=ravi@prevas.dk \
--cc=fra.schnyder@gmail.com \
--cc=francesco@dolcini.it \
--cc=franz.schnyder@toradex.com \
--cc=quentin.schulz@cherry.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.