Robert Elz <> wrote:

> And yes, in particular if a [a\-c] means a class with the three chars 'a' '-'
> and 'c' in it in sh it should mean that in fnmatch() as well, or if that 
> pattern means a class with 8 chars (0x5c .. 0x63) with 'a' there 2 ways,
> in fnmatch() then it should mean that in sh as well. 

My tests verify that all modern shells including ksh93 match three chars for

> On the other hand, having sh allow '' and "" quoting in addition to \ quoting
> while not supporting that in fnmatch() is possible using a technique like
> that in what was intended to be the 985 resolution - just provided that it
> handles all of the cases correctly.

Since '' and "" quoting in the shell is highly complex and no longer present at 
the time the shell pattern matching is called, it makes no sense to add '' and 
"" to fnmatch().

To understand quoting, let me explain how the Bourne Shell does it:

1)      the parser keeps \a and converts 'a' into \a

2)      The parser retains " in strings

3)      The interpreter calls the macro expansion code and this code
        replaces the extended strings inside "" by quote chars (e.g. "abc"
        into \a\b\c).

4)      The file name globbing is done for command arguments and gmatch()
        is called for "case" statements, using the current state of the string
        that reaults in:




If you like to let fnmatch() match the behavior of the shell related to 
character classes, this could be cone using a new flag FNM_CLASSESC.


--                    (home) Jörg Schilling D-13353 Berlin (work) Blog:

Reply via email to