All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Rini <trini@konsulko.com>
To: Rasmus Villemoes <ravi@prevas.dk>
Cc: u-boot@lists.denx.de
Subject: Re: [PATCH 01/11] cmd: test: add support for =~ operator
Date: Tue, 6 May 2025 10:49:31 -0600	[thread overview]
Message-ID: <20250506164931.GA5430@bill-the-cat> (raw)
In-Reply-To: <20250506141035.385756-2-ravi@prevas.dk>

[-- Attachment #1: Type: text/plain, Size: 1162 bytes --]

On Tue, May 06, 2025 at 04:10:25PM +0200, Rasmus Villemoes wrote:

> Currently, the only way to make use of regex matching in the shell is
> by using "setexpr [g]sub" command. That's rather awkward for asking
> whether a string matches a regex. At the very least, it requires
> providing setexpr with a dummy target variable, but also, the return
> value of setexpr doesn't say whether any substitutions were done, so
> one would have to do some roundabout thing like
> 
>   env set dummy "${string_to_test}"
>   setexpr sub dummy '<some regex>' ''
>   if test "${dummy}" != "${string_to_test}" ; then ...
> 
> When CONFIG_REGEX is set, teach the test command a new operator, =~,
> which will allow one to more naturally write
> 
>   if test "${string_to_test}" =~ '<some regex>' ; then ...
> 
> Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>

We should also mention here (and then in docs) that this the same as the
=~ operator in bash, which I only learned about now as part of answering
my own question of "Are people going to expect =~ to do something
else?".

With that,

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

  reply	other threads:[~2025-05-06 16:49 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-06 14:10 [PATCH 00/11] regex patches Rasmus Villemoes
2025-05-06 14:10 ` [PATCH 01/11] cmd: test: add support for =~ operator Rasmus Villemoes
2025-05-06 16:49   ` Tom Rini [this message]
2025-05-06 16:52     ` Tom Rini
2025-05-06 19:07       ` Rasmus Villemoes
2025-05-06 19:24         ` Tom Rini
2025-05-06 21:10           ` Rasmus Villemoes
2025-05-06 14:10 ` [PATCH 02/11] slre: add myself as maintainer Rasmus Villemoes
2025-05-06 14:10 ` [PATCH 03/11] test: slre: add tests for regex library Rasmus Villemoes
2025-05-06 14:10 ` [PATCH 04/11] slre: drop wrong "anchored" optimization Rasmus Villemoes
2025-05-06 14:10 ` [PATCH 05/11] test: slre: add more test cases Rasmus Villemoes
2025-05-06 14:10 ` [PATCH 06/11] test: slre: add some (negative) character class tests Rasmus Villemoes
2025-05-06 14:10 ` [PATCH 07/11] slre: refactor is_any_but() Rasmus Villemoes
2025-05-06 14:10 ` [PATCH 08/11] slre: fix matching of escape sequence used inside character class Rasmus Villemoes
2025-05-06 14:10 ` [PATCH 09/11] test: slre: add test cases for escape char in " Rasmus Villemoes
2025-05-06 14:10 ` [PATCH 10/11] slre: implement support for ranges in character classes Rasmus Villemoes
2025-05-06 14:10 ` [PATCH 11/11] test: slre: add tests for character ranges Rasmus Villemoes
2025-05-06 16:44 ` [PATCH 00/11] regex patches Tom Rini
2025-05-10 11:25 ` 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=20250506164931.GA5430@bill-the-cat \
    --to=trini@konsulko.com \
    --cc=ravi@prevas.dk \
    --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.