From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, T_SCC_BODY_TEXT_LINE,URIBL_CSS autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 12821 invoked from network); 3 Feb 2022 11:13:32 -0000 Received: from 4ess.inri.net (216.126.196.42) by inbox.vuxu.org with ESMTPUTF8; 3 Feb 2022 11:13:32 -0000 Received: from pb-smtp2.pobox.com ([64.147.108.71]) by 4ess; Thu Feb 3 00:29:41 -0500 2022 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 2E24F10A0DA for <9front@9front.org>; Thu, 3 Feb 2022 00:14:08 -0500 (EST) (envelope-from unobe@cpan.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=message-id :to:subject:date:from:in-reply-to:mime-version:content-type :content-transfer-encoding; s=sasl; bh=+llndKpJzx3JgYufn8dlUXrjz O3AeKiofFXvl49DUVA=; b=L2SThSJ+WZr0W0xmVjz32lYG6/hHZTOsj3M0SSGp2 lBEkY/4oIl0NLgHMLIivUq0NDHZeIJHzT6IVneb4c0qu6QmrmiF/gCL147gqmJnt zR30Xfs/lL0sNRjty2HUaNvQdcex04PYVVxxgbE1HttPHpFpZkwbolpdit79tVN0 jA= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 2728210A0D8 for <9front@9front.org>; Thu, 3 Feb 2022 00:14:08 -0500 (EST) (envelope-from unobe@cpan.org) Received: from strider.localdomain (unknown [137.25.136.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id 5A34B10A0D7 for <9front@9front.org>; Thu, 3 Feb 2022 00:14:07 -0500 (EST) (envelope-from unobe@cpan.org) Message-ID: <2E73EA4D5AFD2B48A02296D50A471D1C@smtp.pobox.com> To: 9front@9front.org Date: Wed, 02 Feb 2022 21:14:05 -0800 From: unobe@cpan.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Pobox-Relay-ID: 1CDA2804-84B0-11EC-B608-CB998F0A682E-09620299!pb-smtp2.pobox.com List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: agile leveraged session standard proxy database Subject: Re: [9front] grep: always show path with '-n' Reply-To: 9front@9front.org Precedence: bulk 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); >