bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: find (and friends) bug?


From: fabrice bauzac
Subject: Re: find (and friends) bug?
Date: Sun, 3 Mar 2002 17:06:03 +0100
User-agent: Mutt/1.3.27i

On Sun, Mar 03, 2002 at 02:34:36PM +0000, Hactar wrote:

> See, I just went and checked the original article, and it says "./:".  Maybe
> your news server is doubling initial "."s... dunno.

Maybe...  Anyway.

> I could not get "[[:*:]]" to work with -regex.

> $ touch j , :
> $ find . -name '[[:alpha:]]' -maxdepth 1
> ../:
> ../j

> "j" is not in the set {"[", ":", "a", "l", "p", "h", "]"}.

I have got GNU find 4.1.7 and here is what it says:

$ find . -name '[[:alpha:]]' -maxdepth 1
./j

Look at this:

$ ls -a
,  :  .  ..  a  j
$ LC_ALL=C find --version
GNU find version 4.1.7

This is OK:

$ find . -name '[a-z]'
./j
./a

But look:

$ find . -name '[[:alpha:]]'
./j
./a
It means that -name accepts [:*:].  Is it the normal
behaviour?

The -regex switch understands the simple character classes:

$ find . -regex '.*/[a-z]'
./j
./a

But it doesn't understand POSIX character classes:

$ find . -regex '.*/[[:alpha:]]'  # No output
$ find . -regex '.*/[[:alpha:]'
./:
./a

However it accepts Emacs-style character classes:

$ find . -regex '.*/\w*'
./j
./a

I tend to think that:

* -name works properly in GNU find 4.1.7

* -regex works the way it is documented, i.e. the regular expression
is interpreted as Emacs-style regex.  See the Texinfo documentation,
(find) Full Name Patterns, it explains that the syntax of the regex
for find is the same as Emacs's.  So I don't think it is a bug.

I suggest you upgrade to GNU find version 4.1.7, and maybe you would
like another switch (other than -regex, -iregex) that would support
another regex syntax:

GNU awk regex syntax
POSIX awk regex syntax
egrep regex syntax
POSIX egrep regex syntax
common POSIX syntax
basic POSIX syntax
extended POSIX syntax
...

As you can see, there are many syntaxes for regular expressions.

-- 
fabrice bauzac
Software should be free.  http://www.gnu.org/philosophy/why-free.html



reply via email to

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