[Top][All Lists]

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

Re: Grep --directories option (POSIX)

From: Stepan Kasal
Subject: Re: Grep --directories option (POSIX)
Date: Mon, 2 Jun 2003 10:05:27 +0200
User-agent: Mutt/

        I haven't read whole thread yet, but I hope the following question
is not misleaded:

On Fri, May 30, 2003 at 05:32:06PM -0700, Paul Eggert wrote:
> [...] As I read it, POSIX requires
> that "grep foo dir" must work if one can read dir as if it were a
> file, and if the resulting bytes are the bytes of a text file.  It
> also requires that 'grep' must output a diagnostic and must fail
> (i.e. exit with status 2) if the 'read' fails.

Understanding what POSIX says is really crucial for this issue.

The definition of grep utility says, among other things:

|     The input files shall be text files.


Looking for what ``shall'' means:

|    shall
|   For an implementation [...]
|   For an application or user, describes a behavior that is mandatory.

I understand this that it's mandatory for the user to supply
``text file'' as the arguments.

I can also cite this:

|  Text File
|   [...] many utilities only produce predictable or meaningful output when
|   operating  on text files. The standard utilities that have such
|   restrictions always specify "text files" in their STDIN or INPUT FILES
|   sections.

So it seems that grep is one of these utilities.

If I were true, grep could do anything as soon as someone supplies a
non-text file.  Thus --directories=skip would be legal on most systems.

The exception are sytems where a file can be ``text file'' and directory
at once.  (I haven't heard about any such system except GNU/Hurd.)

Looking forward to your comments,
        Stepan Kasal

reply via email to

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