[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[address@hidden: Grep --directories option]
From: |
Alfred M. Szmidt |
Subject: |
[address@hidden: Grep --directories option] |
Date: |
Fri, 30 May 2003 11:54:20 +0200 |
This might be of interest to everyone...
------- Start of forwarded message -------
Date: Fri, 30 May 2003 09:49:07 +0200
From: Stepan Kasal <kasal@math.cas.cz>
To: bug-grep@gnu.org
Content-Disposition: inline
cc: Jori Mantysalo <Jori.Mantysalo@uta.fi>
cc: Alain Magloire <alain@qnx.com>
cc: Paul Eggert <eggert@twinsun.com>
Subject: Grep --directories option
Sender: bug-gnu-utils-bounces+ams=kemisten.nu@gnu.org
Hello all,
I'd like to ask you how should grep behave if it encounters a directory
as an argument on the command line.
I think that POSIX doesn't have any requiremnets here, as it simply says:
The input files shall be text files.
I infer that if they are not, the behaviour is undefined.
The behaviour is controlled by the --directories option.
There are three possible values:
read: try to read the directory as if it was regular file.
This ``greps through file names'' on some systems
(eg. on ancient Unix or on GNU/Hurd) and produces
an error on other (eg. on Linux and other contemporary
unices).
skip: silently ignore directory parameters
recurse: recurse through them, equivalent to -r or --recurse.
Let me recapitulate the history:
* grep <= 2.0 had ``read'' hardwired
* grep 2.1 and 2.2 had ``skip'' hardwired
* since 2.3 the --directories option is available, read is again
the default
* BUT: grep 2.5 introduced a bug [1], which caused that grep behaved
as if the default was ``skip'' on sustems where reading a directory
is a faux pas.
Well, I'd like to change the default to ``skip'' now.
We don't have to follow the Unix tradition that closely; after all GNU
is not Unix ;-)
I don't like changing the defaults every other release, but remember
that because of the bug, this won't be a visible change for users of
grep version 2.5 or 2.5.1 on modern Unices.
For users on systems where reading a dir is allowed, this will be
a change of the default. But is it really true that people on Hurd
do
grep '^[0-9]\.txt$ dir'
instead of
ls dir | grep '^[0-9]\.txt$'
?
I'd like to hear comments.
Have a nice day,
Stepan Kasal
[1] grep 2.5 introduced a bug, which effectively changed the code
if (! fillbuf (save, stats))
if (! (is_EISDIR (errno, file) && suppress_errors))
error (filename, errno);
to
if (! fillbuf (save, stats))
if (! is_EISDIR (errno, file) && ! suppress_errors)
error (filename, errno);
This is real bug, if there is a problem reading dir contents.
If no serious error occurs, this only suppresses the "Is a directory"
messages.
_______________________________________________
Bug-gnu-utils mailing list
Bug-gnu-utils@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-gnu-utils
------- End of forwarded message -------
- [address@hidden: Grep --directories option],
Alfred M. Szmidt <=