dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephane Chazelas <stephane@chazelas.org>
To: Harald van Dijk <harald@gigawatt.nl>
Cc: Eric Blake <eblake@redhat.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	calestyo@scientia.org, dash@vger.kernel.org
Subject: Re: [v2 PATCH] expand: Always quote caret when using fnmatch
Date: Mon, 21 Feb 2022 19:15:15 +0000	[thread overview]
Message-ID: <20220221191515.gz2js45fm3ya265u@chazelas.org> (raw)
In-Reply-To: <6232ed8d-1c18-49ce-a7be-9e382245b5cc@gigawatt.nl>

2022-02-21 17:06:13 +0000, Harald van Dijk:
> > If you want to escape ^ to always be treated as a literal when calling
> > fnmatch(), you have to spell it something like [[=^=]...], not [\^...]
> > (that is, since \^ inside [] does NOT treat the \ as an escape
> > character, but as yet another literal character as part of the brakcet
> > group, you instead have to resort to calling out the literal character
> > ^ via alternative spellings such as by a collation equivalent).
> This is correct for regular expressions, unspecified for shell patterns in
> general after bug 1234 was resolved, and always incorrect for fnmatch()
> after bug 1190 was resolved. In fnmatch(), backslash has to work even inside
> bracket expressions. Whether it had to may not previously have been clear in
> the standard, but it has been made clear now and that is also how it works
> in glibc. That part of the patch is not a problem.

Thanks, and sorry about that. I was actually the one raising bug
1234 and misremembered the outcome.

case $var in ([\!x])

is specified, but:

case $var in ($pattern)

is not indeed, so, the behaviour  of:

sh -c 'case "\\" in ($1) echo match; esac' sh '[\^x]'

is unspecified, so even though that patch changes the behaviour
in this instance, it's still not a conformance bug.


  reply	other threads:[~2022-02-21 19:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-12 16:25 possible wrong behaviour with patterns using a quoted ^ at the start of a bracket expression Christoph Anton Mitterer
2022-01-12 17:20 ` Harald van Dijk
2022-01-12 17:47   ` Christoph Anton Mitterer
2022-01-12 18:17     ` Harald van Dijk
2022-01-12 18:21       ` Christoph Anton Mitterer
2022-01-18  6:13   ` [PATCH] expand: Always quote caret when using fnmatch Herbert Xu
2022-01-18  8:44     ` Harald van Dijk
2022-01-19  5:37       ` [v2 PATCH] " Herbert Xu
2022-02-20  7:15         ` Stephane Chazelas
2022-02-21 16:39           ` Eric Blake
2022-02-21 17:06             ` Harald van Dijk
2022-02-21 19:15               ` Stephane Chazelas [this message]
2022-01-18 14:29     ` [PATCH] " Christoph Anton Mitterer
2022-01-18 14:54       ` Chet Ramey
2022-01-18 22:33       ` Herbert Xu

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:

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

  git send-email \
    --in-reply-to=20220221191515.gz2js45fm3ya265u@chazelas.org \
    --to=stephane@chazelas.org \
    --cc=calestyo@scientia.org \
    --cc=dash@vger.kernel.org \
    --cc=eblake@redhat.com \
    --cc=harald@gigawatt.nl \
    --cc=herbert@gondor.apana.org.au \
    --subject='Re: [v2 PATCH] expand: Always quote caret when using fnmatch' \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).