public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug glob/28792] New: possible wrong behaviour with patterns with double [ with no closing ]
@ 2022-01-18 14:21 calestyo at scientia dot org
  2022-01-24 16:17 ` [Bug glob/28792] " schwab@linux-m68k.org
  2022-01-24 16:28 ` calestyo at scientia dot org
  0 siblings, 2 replies; 3+ messages in thread
From: calestyo at scientia dot org @ 2022-01-18 14:21 UTC (permalink / raw)
  To: glibc-bugs

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

            Bug ID: 28792
           Summary: possible wrong behaviour with patterns with double [
                    with no closing ]
           Product: glibc
           Version: 2.33
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: glob
          Assignee: unassigned at sourceware dot org
          Reporter: calestyo at scientia dot org
  Target Milestone: ---

Hey.

Forwarding this from:

https://lore.kernel.org/dash/YeZbt7nhvODBSL0I@gondor.apana.org.au/T/#mb9438ab3009b9e38a2e22fdd22e99ddd74078b93

where it was suggested that this may be a bug in fnmatch().



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.
(see POSIX,
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13
)


That seems to work in dash (which according to its maintainer uses fnmatch()
for the matching):
$ 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 (no idea whether that uses fnmatch() too), but neither
in busybox sh, nor klibc sh.


Thanks,
Chris.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug glob/28792] possible wrong behaviour with patterns with double [ with no closing ]
  2022-01-18 14:21 [Bug glob/28792] New: possible wrong behaviour with patterns with double [ with no closing ] calestyo at scientia dot org
@ 2022-01-24 16:17 ` schwab@linux-m68k.org
  2022-01-24 16:28 ` calestyo at scientia dot org
  1 sibling, 0 replies; 3+ messages in thread
From: schwab@linux-m68k.org @ 2022-01-24 16:17 UTC (permalink / raw)
  To: glibc-bugs

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

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED
   Target Milestone|---                         |2.35

--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> ---
Fixed in 2.35.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug glob/28792] possible wrong behaviour with patterns with double [ with no closing ]
  2022-01-18 14:21 [Bug glob/28792] New: possible wrong behaviour with patterns with double [ with no closing ] calestyo at scientia dot org
  2022-01-24 16:17 ` [Bug glob/28792] " schwab@linux-m68k.org
@ 2022-01-24 16:28 ` calestyo at scientia dot org
  1 sibling, 0 replies; 3+ messages in thread
From: calestyo at scientia dot org @ 2022-01-24 16:28 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #2 from Christoph Anton Mitterer <calestyo at scientia dot org> ---
Thanks :-)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2022-01-24 16:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-18 14:21 [Bug glob/28792] New: possible wrong behaviour with patterns with double [ with no closing ] calestyo at scientia dot org
2022-01-24 16:17 ` [Bug glob/28792] " schwab@linux-m68k.org
2022-01-24 16:28 ` calestyo at scientia dot org

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 read-only IMAP folder(s) and NNTP newsgroup(s).