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

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

Re: New grep feature (patch to 2.5e attached)


From: Paul Eggert
Subject: Re: New grep feature (patch to 2.5e attached)
Date: Tue, 22 May 2001 14:25:33 -0700 (PDT)

> Date: Tue, 22 May 2001 00:40:07 -0400 (EDT)
> From: "Alain Magloire" <address@hidden>

> I'm not sure I follow, you mean:
>  -r,                ignore special files when going through directories
>  -R, --recursive    grep to everything special files are not
> 
> If this the behaviour of GNU cp, it would be good to be consistent.

Yes, that's pretty much it.  The GNU cp documentation says:

   `-r'
        Copy directories recursively, copying any non-directories and
        special files (e.g., symbolic links, FIFOs and device files) as if
        they were regular files.

   `-R'
   `--recursive'
        Copy directories recursively, preserving non-directories (contrast
        with `-r' just above).

POSIX 1003.1-200x d6 says that 'cp -r' has implementation-defined
behavior on special files; GNU 'cp' has the historical BSD behavior.

There are really two independent questions here:

* Should symbolic links be followed?
* Should all non-directories be read as if they were were regular files?

GNU cp's -r option causes both questions to be answered "yes",
and its -R option causes both questions to be answered "no".

I guess grep could have two separate options, to answer each question
independently.  However, in practice this flexibility doesn't seem to
be needed, at least not for GNU cp.


While we're on the subject, POSIX d6 also specifies the following options
for cp, which are taken from BSD:

  -H  Follow symbolic links on the command-line, but not other symbolic links.
  -L  Follow all symbolic links.
  -P  Do not follow any symbolic links.

The default is unspecified by POSIX, but I think GNU cp follows BSD cp
in making -H the default.

(-L is also called '--dereference' in GNU cp; -P is also called
--no-dereference.  There is no long option for -H, but I would suggest
'--dereference-command-line'.  GNU cp uses -P for something else in
fileutils 4.1, but this will soon change to conform to POSIX d6.)

This sounds to me like a good model for GNU grep, though you may have
to omit the short option letters for grep, as -H and -L already mean
something else.



reply via email to

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