bug-grep
[Top][All Lists]
Advanced

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

Re: [bug-grep] rewriting the main loop


From: Stepan Kasal
Subject: Re: [bug-grep] rewriting the main loop
Date: Mon, 28 Feb 2005 10:13:02 +0100
User-agent: Mutt/1.4.1i

Hello.

On Sun, Feb 27, 2005 at 06:43:44PM +0100, Claudio Fontana wrote:
> Currently handling of directories is one of
> READ_DIRECTORIES, RECURSE_DIRECTORIES and
> SKIP_DIRECTORIES, the default being READ_DIRECTORIES.
> 
> Q: Would it make sense (and would it be ok with posix)
> to make the standard behaviour SKIP_DIRECTORIES?

[ There was a very long discussion on this topic on bug-gnu-utils
a year or two ago.  I don't want to go through it again.  I have
formed my mind back then.  To answer the question: ]

> Q: Would it make sense (and would it be ok with posix)
> to make the standard behaviour SKIP_DIRECTORIES?

No.  Posix requires DIRECTORIES_READ behaviour, and doesn't mention
any way to change it.

Though GNU default _could_ be different, I don't think it's good in
this case.

The error messages, which can be annoying, indeed, are giving you
opportunity to think about another default (either skip or recurse,
according to your taste) via GREP_OPTIONS or to define an alias.

If you are supposing any other config, and happen to have
DIRECTORIES_READ (on another account, for example), you cannot be
misled by the results.  You can be annoyed, but that's not so bad.

An example: Let's imagine we had "skip" as the default.
Imagine "README" is a directory and you grep it.
If you were supposing that you have "read", but you haven't
(you are logged as the root, for example, without any GREP_OPTIONS
setting), then grep would *skip* the directory without notifying you.
The same if you expected "recurse" and defaulted to "skip".

"read" is much safer default.

> On READ_DIRECTORIES maybe we could try to really read
> the directory ... try read(2)

... and nothing else.

This is what we shoul do: to behave as if we never heard that
directories exist.

The subtle reason is that it is possible that a directory can also be a
text file.  A (special configured) GNU HURD system was given as an example.
When you access it as a regular file, it's an XML file, of you read it as
a dir, it's a directory.
Sounds weird, but POSIX allows that.

OK, I ended up giving examples and explanations, tempting you to react on
them.  Yet I'd like to beg you not to react on this.

Please forgive me the tone of this mail.  I think long discussion of this
problem wouldn't help us at all.  Allow me to code the 2.5.2 so that it
does what pre-2.5 grep did, and what the documentation said all the time.

If you think the default should be changed, please postpone the discussion
after we open the development branch, ie. grep-2.6.

Thank you all for every mail you won't send! ;-)

Have a nice day,
        Stepan




reply via email to

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