dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* possible wrong behaviour with patterns double [ with no closing ]
@ 2022-01-17  3:23 Christoph Anton Mitterer
  2022-01-18  6:18 ` Herbert Xu
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Anton Mitterer @ 2022-01-17  3:23 UTC (permalink / raw)
  To: dash

Hey.


Assuming a pattern of:
[.*^\]
my understanding was that this would actually mean:
- the literal string [. followed by
- the pattern notation special character * (i.e. any string) followed by
- the literal string ^]

Because ] is escaped, it's to be taken literally and in a pattern a [
without corresponding ] is to be taken literally as well.

That seems to work in dash:
$ case '[.^]' in ([.*^\]) echo match;; (*) echo no match;; esac
match
$ case '[.x^]' in ([.*^\]) echo match;; (*) echo no match;; esac
match
$ case '[.xx^]' in ([.*^\]) echo match;; (*) echo no match;; esac
match


However, adding another [ to the pattern:
[.*^[\]
which should be:
- the literal string [. followed by
- the pattern notation special character * (i.e. any string) followed by
- the literal string ^[]

No longer matches:
$ case '[.^[]' in ([.*^[\]) echo match;; (*) echo no match;; esac
no match
$ case '[.x^[]' in ([.*^[\]) echo match;; (*) echo no match;; esac
no match
$ case '[.xx^[]' in ([.*^[\]) echo match;; (*) echo no match;; esac
no match


Whereas, AFAIU POSIX, it should.

This works, btw. in bash, but neither in busybox sh, nor klibc sh.


Cheers,
Chris.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: possible wrong behaviour with patterns double [ with no closing ]
  2022-01-17  3:23 possible wrong behaviour with patterns double [ with no closing ] Christoph Anton Mitterer
@ 2022-01-18  6:18 ` Herbert Xu
  2022-01-18 14:28   ` Christoph Anton Mitterer
  2022-01-24 16:26   ` Christoph Anton Mitterer
  0 siblings, 2 replies; 5+ messages in thread
From: Herbert Xu @ 2022-01-18  6:18 UTC (permalink / raw)
  To: Christoph Anton Mitterer; +Cc: dash

Christoph Anton Mitterer <calestyo@scientia.org> wrote:
>
> This works, btw. in bash, but neither in busybox sh, nor klibc sh.

This happens only with fnmatch.  So I would presume that it's
a bug in glibc and you can take it up with them.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: possible wrong behaviour with patterns double [ with no closing ]
  2022-01-18  6:18 ` Herbert Xu
@ 2022-01-18 14:28   ` Christoph Anton Mitterer
  2022-01-24 16:26   ` Christoph Anton Mitterer
  1 sibling, 0 replies; 5+ messages in thread
From: Christoph Anton Mitterer @ 2022-01-18 14:28 UTC (permalink / raw)
  To: Herbert Xu; +Cc: dash

On Tue, 2022-01-18 at 17:18 +1100, Herbert Xu wrote:
> This happens only with fnmatch.  So I would presume that it's
> a bug in glibc and you can take it up with them.

Forwarded to:

https://sourceware.org/bugzilla/show_bug.cgi?id=28792


Cheers,
Chris.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: possible wrong behaviour with patterns double [ with no closing ]
  2022-01-18  6:18 ` Herbert Xu
  2022-01-18 14:28   ` Christoph Anton Mitterer
@ 2022-01-24 16:26   ` Christoph Anton Mitterer
  2022-01-25  0:36     ` Herbert Xu
  1 sibling, 1 reply; 5+ messages in thread
From: Christoph Anton Mitterer @ 2022-01-24 16:26 UTC (permalink / raw)
  To: Herbert Xu; +Cc: dash

On Tue, 2022-01-18 at 17:18 +1100, Herbert Xu wrote:
> This happens only with fnmatch.  So I would presume that it's
> a bug in glibc and you can take it up with them.

FYI:

Was apparently fixed in git:
https://sourceware.org/git/?p=glibc.git;a=commit;h=8442f0d966da5a9333e961af9e98b41aabdd9f1b


Cheers,
Chris.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: possible wrong behaviour with patterns double [ with no closing ]
  2022-01-24 16:26   ` Christoph Anton Mitterer
@ 2022-01-25  0:36     ` Herbert Xu
  0 siblings, 0 replies; 5+ messages in thread
From: Herbert Xu @ 2022-01-25  0:36 UTC (permalink / raw)
  To: Christoph Anton Mitterer; +Cc: dash

On Mon, Jan 24, 2022 at 05:26:16PM +0100, Christoph Anton Mitterer wrote:
> On Tue, 2022-01-18 at 17:18 +1100, Herbert Xu wrote:
> > This happens only with fnmatch.  So I would presume that it's
> > a bug in glibc and you can take it up with them.
> 
> FYI:
> 
> Was apparently fixed in git:
> https://sourceware.org/git/?p=glibc.git;a=commit;h=8442f0d966da5a9333e961af9e98b41aabdd9f1b

Thanks Chris!
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-01-25  3:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-17  3:23 possible wrong behaviour with patterns double [ with no closing ] Christoph Anton Mitterer
2022-01-18  6:18 ` Herbert Xu
2022-01-18 14:28   ` Christoph Anton Mitterer
2022-01-24 16:26   ` Christoph Anton Mitterer
2022-01-25  0:36     ` Herbert Xu

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).