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

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

Re: Grep -r with no files should imply ./


From: Stepan Kasal
Subject: Re: Grep -r with no files should imply ./
Date: Sun, 8 Feb 2004 10:55:29 +0100
User-agent: Mutt/1.4.1i

Hello,

On Fri, Feb 06, 2004 at 07:16:15PM -0600, Tom Felker wrote:
> When I mean "grep -r foo ." but type "grep -r foo", grep just waits for input 
> until I notice my disk not chugging and correct my mistake: the --recursive 
> option has no effect unless there are input files.  Since I usually mean to 
> search the current directory, I think --recursive should cause the input to 
> default to . instead of stdin.
> 
> If someone applies this, it'll save me a lot of typing.  Please cc: me.

I have the same experience as you, and I have considered this idea before.

There is a problem, though:
-r, --recursive is the same as --directories=recurse

--directories=xxx is one of the options which are likely to be set in the
environment variable GREP_OPTIONS, in order to customize grep to one's
preferences.

If a user thinks that --directories=recurse is better than `skip' or `read',
they may set GREP_OPTIONS="--directories=recurse" .
It would be unfortunate if that broke eg. the following:
        dmesg | grep abc

grep could behave differently when -r is given on cmd. line, not via
GREP_OPTIONS.  Or grep could look whether the stdin is a tty. 
But I don't like these kludges.

It's difficult to decide; perhaps the best way is to say that -r, --recursive
behaves differently then --directories=recurse.

What do you think?

Stepan Kasal




reply via email to

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