Geoff Clare <> wrote:

> > Maybe, I should again mention history:
> > 
> >     -       fmnatch() has been introduced with issue 4 (1995). It does not
> >             seem to be related to a historic UNIX. Since the oldest known
> >             implementation is from IBM, fnmatch() may have been introduced
> >             by AIX.
> It was first standardised in POSIX.2-1992 and was invented by the developers
> of that standard.

So fnmatch() could be seen as an artificial invention and there is no need to 
have fnmatch() to behave the same as the shell. 

It would however be nive to be able to switch it into that mode (see my 
FNM_CLASSESC proposal.

> You are conflating two different type of backslash escape.
> The shell should honour backslash when used as shell quoting, regardless
> of whether it is inside a bracket expression, but should not treat a
> backslash in a bracket expression *that is part of the pattern* (i.e. not
> shell quoting) as special.
> For example:
> [\"]     the backslash quotes the "

This string is converted to [\"] by the parser and there is no PS2 prompt.

> ["a\-c"] the backslash is not special and should be treated literally

This string is converted into [\a\\-\c] by the shell macro expansion code.

With the shell gmatch() code, this results in a match for 'a' and '\\' .. 'c'.

So I guess that you missinterpret my text and the results from my test script.

Let me add an updated version that includes a test for "-":

mkdir td && cd td || exit

:> a
echo [a-c] ["a-c"] [\a\-\c] [a\-c]
rm a

:> b
echo [a-c] ["a-c"] [\a\-\c] [a\-c]
rm b

:> ./-
echo [a-c] ["a-c"] [\a\-\c] [a\-c]
rm ./-

:> c
echo [a-c] ["a-c"] [\a\-\c] [a\-c]
rm c

:> _
echo [a-c] ["a-c"] [\a\-\c] [a\-c]
rm _

:> \\
echo [a-c] ["a-c"] [\a\-\c] [a\-c]
rm \\

:> d
echo [a-c] ["a-c"] [\a\-\c] [a\-c]
rm d

rm -f *
cd ..
rmdir td


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

Reply via email to