bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Behavior of glob/fnmatch with square brackets


From: David W. Bettis
Subject: Behavior of glob/fnmatch with square brackets
Date: Tue, 5 Aug 2003 19:52:37 +0000
User-agent: Mutt/1.4i

Greetings,

Consider the following snippet of code:


        int    result_code;

        /* check to see if [foo]/bar matches the pattern [foo]/* */
        if((result_code = fnmatch("\\[foo\\]/*", "\\[foo\\]/bar", 0)) == 0)
        {
                printf("we have a match.\n");
        }
        if(result_code == FNM_NOMATCH)
        {
                printf("no match.\n");
        }


I would suspect this to successfully match; yet, it doesn't.  Wildcards for
matching include ?, *, and [ (character classes).  Escaping the braces should
cause them to match as _regular characters_.

Is this the appropriate behavior?

Thanks for your time.

Kindest regards,
--Dave






reply via email to

[Prev in Thread] Current Thread [Next in Thread]