Subject: bug#14391: bug in grep -- ignoring GREP_OPTIONS or not acting on it...

From: Bob Proulx <[email-masked]>
Date: Sun, 12 May 2013 17:57:06 -0600

Of course this needs to go over to bug-grep but here is my comment
anyway...

Linda Walsh wrote:
> when I type grep, I get an alias + I have GREP_OPTIONS set..
> grep is aliased to `grep --color=auto'
> > echo $GREP_OPTIONS
> -D skip --binary-files=without-match
> Ishtar:/tmp/test> grep foo *
> grep: a: Is a directory
> grep: b: Is a directory
> grep: c: Is a directory

Basically:

  grep -D skip --binary-files=without-match --color=auto foo *

> grep should ignore the directories and issue no message for them:
>        -D ACTION, --devices=ACTION
>            If an input file is a device, FIFO or socket, use ACTION to
>            process  it.   By  default,  ACTION  is  read,  which means that
>            devices are read just as if they were ordinary files.  If ACTION
>            is skip, devices are silently skipped.
>            ...
> ...
> I don't remember this being this way before -- it used to work.
> Seems like it stopped recently?

I think you need --directories=skip in addition to --devices=skip.
Add -d skip to your option list.

  grep -D skip -d skip --binary-files=without-match --color=auto foo *

This is an example of why I think grep should never have added
directory recursion.  It needs to suck in all of 'find' before it will
be complete.  And that doesn't make sense because there is already
find available.

  find . -type f -exec grep foo {} +

That isn't precisely the same as the grep case you posted but it is
usually what people want.  For -D skip it would need to be more like
this:

  find . -follow ! -type d -exec grep foo {} +

If there were often used favorite options then I would turn them into
either a shell script or a shell function.

Bob