Re: [PATCH] Don't push /dev/null as an argument of grep when -c is required.

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

 



On Tue, Sep 11, 2007 at 10:58:04PM +0000, Junio C Hamano wrote:
> Pierre Habouzit <madcoder@xxxxxxxxxx> writes:
> 
> > Signed-off-by: Pierre Habouzit <madcoder@xxxxxxxxxx>
> > ---
> >  builtin-grep.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/builtin-grep.c b/builtin-grep.c
> > index e13cb31..b93fa00 100644
> > --- a/builtin-grep.c
> > +++ b/builtin-grep.c
> > @@ -261,7 +261,7 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached)
> >  	 *
> >  	 * GNU grep has "-H", but this is portable.
> >  	 */
> > -	if (!opt->name_only && !opt->unmatch_name_only)
> > +	if (!opt->name_only && !opt->unmatch_name_only && !opt->count)
> >  		push_arg("/dev/null");
> >  
> >  	hit = 0;
> 
> I am afraid this does not work either.
> 
> The /dev/null here is to avoid sending a singleton filename to
> the external grep when we need to split the argument list, as
> output from "grep foo A B" and concatenation of output from
> "grep foo A" and "grep foo B" are different.

  oh, right, now I get it, I was confused by the comment before that
code, now that you explain it it looks more obvious. So the better fix
is that when we split, we should never be in the case when you have a
singleton :) that should be not that hard.

-- 
·O·  Pierre Habouzit
··O                                                madcoder@xxxxxxxxxx
OOO                                                http://www.madism.org

Attachment: pgprYx04RTpQx.pgp
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux