[Top][All Lists]

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

Re: Behavior of glob/fnmatch with square brackets

From: David W. Bettis
Subject: Re: Behavior of glob/fnmatch with square brackets
Date: Tue, 5 Aug 2003 20:43:34 +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)

> Code and comment disagree, so probably both are wrong.

Code and comment DO agree.

[foo]     (directory)
`-- bar        (file)
`-- baz        (file)

The "human-readable" path is

However, to match the raw braces (not to indicate that foo
is a character class for {f,o,o}), we have to escape them:

Then, we add C-style escaping to it:

The intent is to match ALL files under the directory '[foo]'.

Thanks again,


reply via email to

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