9front - general discussion about 9front
 help / color / mirror / Atom feed
From: unobe@cpan.org
To: 9front@9front.org
Subject: Re: [9front] grep: always show path with '-n'
Date: Wed, 02 Feb 2022 21:14:05 -0800	[thread overview]
Message-ID: <2E73EA4D5AFD2B48A02296D50A471D1C@smtp.pobox.com> (raw)
In-Reply-To: <EC7AE28A319953480E1CA64DF9DC4BE3@eigenstate.org>


Makes sense to me.

Quoth ori@eigenstate.org:
> With the new 'g', I noticed that sometimes
> we'd fail to show the filename; this happens
> because 'g' now uses xargs, and if there's
> exactly one file picked up by xargs, the
> Hflag does not get set.
> 
> This change makes grep now print the filename
> if Hflag *or* Nflag is set, which is what I'd
> expect.
> 
> Before:
> 
> 	% grep -n -- Nflag main.c
> 	106: 		flag |= Nflag;		/* count only */
> 
> After:
> 
> 	% grep -n -- Nflag main.c
> 	main.c:106: 		flag |= Nflag;		/* count only */
> 
> And it still does something sensible for stdin:
> 
> 	% grep -n asdf
> 	asdf
> 	stdin:1: asdf
> 
> Does this make sense to people?
> 
> 
> diff 251c3cfd610abd169676852d301a2aa1267c0e57 uncommitted
> --- a/sys/src/cmd/grep/main.c
> +++ b/sys/src/cmd/grep/main.c
> @@ -180,7 +180,7 @@
>  			count++;
>  			if(flag & (Cflag|Sflag|Llflag|LLflag))
>  				goto cont;
> -			if(flag & Hflag)
> +			if(flag & (Hflag|Nflag))
>  				Bprint(&bout, "%s:", file);
>  			if(flag & Nflag)
>  				Bprint(&bout, "%ld: ", lineno);
> @@ -219,7 +219,7 @@
>  			count++;
>  			if(flag & (Cflag|Sflag|Llflag|LLflag))
>  				goto conti;
> -			if(flag & Hflag)
> +			if(flag & (Hflag|Nflag))
>  				Bprint(&bout, "%s:", file);
>  			if(flag & Nflag)
>  				Bprint(&bout, "%ld: ", lineno);
> 


  reply	other threads:[~2022-02-03 11:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-02 23:01 ori
2022-02-03  5:14 ` unobe [this message]
2022-02-03  7:04 ` Steve Simon
2022-02-03 16:47   ` ori
2022-02-03 19:04     ` Nicola Girardi
2022-02-04  0:47       ` ori
2022-02-04  0:48       ` ori
2022-02-04 22:00         ` Nicola Girardi
2022-02-05 16:57           ` hiro
2022-02-05 17:06             ` Stanley Lieber
2022-02-05 18:00               ` hiro
2022-02-04 12:39       ` Alex Musolino
2022-02-05  4:58 ` 有澤 健治

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2E73EA4D5AFD2B48A02296D50A471D1C@smtp.pobox.com \
    --to=unobe@cpan.org \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).