All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rasmus Villemoes <ravi@prevas.dk>
To: Quentin Schulz <quentin.schulz@cherry.de>
Cc: <u-boot@lists.denx.de>,  Tom Rini <trini@konsulko.com>
Subject: Re: [PATCH 1/3] cmd: test: allow using [ as alias for test
Date: Wed, 11 Mar 2026 14:25:28 +0100	[thread overview]
Message-ID: <873426qz07.fsf@prevas.dk> (raw)
In-Reply-To: <abd3d7c1-b56e-4639-85d8-3083f9d0842b@cherry.de> (Quentin Schulz's message of "Wed, 11 Mar 2026 14:08:33 +0100")

On Wed, Mar 11 2026, Quentin Schulz <quentin.schulz@cherry.de> wrote:

> Hi Rasmus,
>
> On 3/11/26 1:09 PM, Rasmus Villemoes wrote:
>> I often find myself writing something like
>>    if [ "$somevar" = 123 ] ; then ...
>> only to realize that that syntax doesn't work in U-Boot shell, and
>> must be spelled
>>    if test "$somevar" = 123 ; then
>> It only takes a few lines of code to support this POSIX-standardized
>> alias for test, and helps developers focus on their actual problems
>> instead of dealing with such unexpected quirks of the shell.
>> Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>
>> ---
>>   cmd/test.c | 19 +++++++++++++++++++
>
> Please don't forget to update the docs. It still states "Unlike in
> ordinary shells, it cannot be spelled [.",
> c.f. https://docs.u-boot.org/en/latest/usage/cmd/test.html#description. The
> synopsis should also have a few examples using the new syntax.

Ah, yes, thanks. Rather amazing that I could complete forget having
written that only 10 months ago...

Will update.

> Another question is if you have thought about/tested multi-expressions?
>
> e.g.
>
> [ aaa = aaa -a bbb = bbb ]
>
> and possibly also
>
> [ ! aaa = aaa ]
>

Yes, I did think about those, and I can certainly copy-paste a few more
test cases and spell them using [], but as the implementation is so
simple (check last argv, decrement argc) I couldn't really imagine those
being any different than the simple cases.

> I think adding tests for those would be nice too?

Sure, will do.

Rasmus

  reply	other threads:[~2026-03-11 13:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-11 12:09 [PATCH 0/3] add [ as alias for test, fix 0/1 argument handling Rasmus Villemoes
2026-03-11 12:09 ` [PATCH 1/3] cmd: test: allow using [ as alias for test Rasmus Villemoes
2026-03-11 13:08   ` Quentin Schulz
2026-03-11 13:25     ` Rasmus Villemoes [this message]
2026-03-11 12:09 ` [PATCH 2/3] test: add tests for left-bracket alias for 'test' command Rasmus Villemoes
2026-03-16  2:43   ` Simon Glass
2026-03-16  8:16     ` Rasmus Villemoes
2026-03-17 12:28       ` Simon Glass
2026-03-17 15:11         ` Rasmus Villemoes
2026-03-18  1:03           ` Simon Glass
2026-03-11 12:09 ` [PATCH 3/3] cmd: test: fix handling of single-argument form of test Rasmus Villemoes
2026-03-16  2:43   ` Simon Glass

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=873426qz07.fsf@prevas.dk \
    --to=ravi@prevas.dk \
    --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.