mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: Denys Vlasenko <vda.linux@googlemail.com>
Cc: Rich Felker <dalias@libc.org>, musl <musl@lists.openwall.com>
Subject: Re: fnmatch bug? escaping of '-' and ']' inside [...] does not work.
Date: Tue, 15 Aug 2017 16:25:50 +0200	[thread overview]
Message-ID: <20170815142550.GM15263@port70.net> (raw)
In-Reply-To: <CAK1hOcPAE-usFVzRrNMV0QPZPErX8Dww0hA3GjkoC1xAKxXjHA@mail.gmail.com>

* Denys Vlasenko <vda.linux@googlemail.com> [2017-08-15 15:12:17 +0200]:
> Moving bbox build to musl did uncover one definite bug.
> bbox has gazillion tests for its shells, and one of them
> started failing. I added debug printout and with it,
> the following fnmatch calls give different results now:
> 
> ash: fnmatch(pattern:'[a\-c]',str:'-',0):1
> ash: fnmatch(pattern:'[\]]',str:']',0):1
> ash: fnmatch(pattern:'[a\]]',str:']',0):1
> 
> glibc and uclibc threat the above as a match.
> 
> The assumption may be that one should place ']' or '-'
> as a first character in the [...] and thus escaping
> is not necessary, but shell does not have the luxury
> of choosing the pattern, in comes from the script.
> 

it's not clear to me if \ is valid as escape in fnmatch pattern:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13_01

in re bracket expression \ is not an escape char,
but in the shell i think the pattern should be
unquoted first, which may or may not apply to
fnmatch bracket expression, depending on how you
read the text.

i guess if other implementations do the unquoting
musl should follow that, but the standard could
be improved.


  reply	other threads:[~2017-08-15 14:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-15 13:12 Denys Vlasenko
2017-08-15 14:25 ` Szabolcs Nagy [this message]
2017-08-15 14:28 ` Rich Felker

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=20170815142550.GM15263@port70.net \
    --to=nsz@port70.net \
    --cc=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    --cc=vda.linux@googlemail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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