Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Tue, 14 Oct 2014 21:58:26 +0200
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Subject: Re: fnmatch test question

* Justin Cormack <justin@...cialbusservice.com> [2014-10-14 20:02:18 +0100]:
> 
> fnmatch("[[?*\\]", "\\", 0) == 0;
> fnmatch("[]?*\\]", "]", 0) == 0;
> 
> These do not pass on glibc, FreeBSD or NetBSD, they seem to rely on a
> view that \ should not be special inside a bracket expression.
> 

yes these tests follow the re bracket spec

> However, this is for an RE bracket expression which is not exactly the
> same as an fnmatch one and the fnmatch definition
> http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_13_01
> says
> 
> When pattern matching is used where shell quote removal is not
> performed (such as in the argument to the find - name primary when
> find is being called using one of the exec functions as defined in the
> System Interfaces volume of IEEE Std 1003.1-2001, or in the pattern
> argument to the fnmatch() function), special characters can be escaped
> to remove their special meaning by preceding them with a backslash

i read it as

"when pattern matching is used [...] in the pattern argument
to the fnmatch function, special characters can be escaped"

so fnmatch bracket is not like re bracket..

this is news to me

> character. This escaping backslash is discarded. The sequence "\\"
> represents one literal backslash. All of the requirements and effects
> of quoting on ordinary, shell special, and special pattern characters
> shall apply to escaping in this context.

i wonder how the shell is supposed to use the fnmatch api..

> Which is perhaps contradictory, or maybe just unclear. I tend to think
> that Musl is correct form this spec, but not that convinced that I can
> currently persuade anyone to change what appears to be standard
> practise - any advice?

i think musl is not correct, but the requirement about what
can be escaped where could be clearer

> 
> Justin

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.