bug-grep
[Top][All Lists]
Advanced

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

Re: [bug-grep] --include / --exclude


From: Stepan Kasal
Subject: Re: [bug-grep] --include / --exclude
Date: Wed, 8 Dec 2004 15:00:11 +0100
User-agent: Mutt/1.4.1i

Hi Benno,
  there are not many voices protesting against applying --exclude
to dir names, so I'm going to put it to the docs for now.

On Fri, Dec 03, 2004 at 01:05:40PM +0100, Benno Schulenberg wrote:
> But my expectations are that if --include='*.c' does not search only 
> those directories that happen to end in ".c", then --exclude='.svn' 
> does not exclude any directories.
> The --include and --exclude options should be symmetrical, for my 
> taste.

If your mind us working in this logical way, I can recommend you using

find ... | xargs -r grep -H pattern

This is much more consistent.  And, of course, you can make a shell
wrapper:

pat=$1
pgm=$2
shift 2
find "$@" \( $pgm \) -type f -print0 | xargs -0r grep -H "$pat"

and call it like
 
myrgrep foo "-type d -name .svn -prune -o ! -name '*po'" dir1 dir2

> I would be sour if a grep -r pattern --exclude='*py' would 
> exclude some subdir that happened to be called "copy".

I'm afraid it's the way it'll be, sorry.

The option --exclude is meant only for very simple cases.
Usually, one distinguishes files by extensions, eg. --exclude='*.py'
And directory names usually don't have these extensions, it would be
confusing.

> (If you want the ability to exclude dirs, then go with the #3521 
> patch and get the ability to include only certain dirs too.)

No, I definitely don't want yet another find option to grep.

Have a nice day,
        Stepan




reply via email to

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