From owner-freebsd-hackers@freebsd.org Wed May 27 09:06:54 2020 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9DEE232CB6D for ; Wed, 27 May 2020 09:06:54 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49X4hZ3c5Wz40ch; Wed, 27 May 2020 09:06:54 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from ivaldir.etoilebsd.net (etoilebsd.net [178.32.217.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: bapt) by smtp.freebsd.org (Postfix) with ESMTPSA id 6021E17C9A; Wed, 27 May 2020 09:06:54 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: by ivaldir.etoilebsd.net (Postfix, from userid 1001) id 34BC4C2475; Wed, 27 May 2020 11:06:52 +0200 (CEST) Date: Wed, 27 May 2020 11:06:52 +0200 From: Baptiste Daroussin To: Fehmi Noyan ISI Cc: Yuri Pankov , freebsd-hackers@freebsd.org Subject: Re: diff(1) -N behaviour - Bug 233402 Message-ID: <20200527090652.dubjpd2y2n5yfbta@ivaldir.net> References: <94a82a22-b5c9-b797-30cc-0242f6da1c8a@fastmail.com> <4ADEBC26-0F93-45C1-B775-E6E33E95FDC1@yahoo.com> <0E0FB885-5D64-41F1-9A8B-8CEDB5884762@yahoo.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="24ygsgv57ix6tldz" Content-Disposition: inline In-Reply-To: <0E0FB885-5D64-41F1-9A8B-8CEDB5884762@yahoo.com> X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 May 2020 09:06:54 -0000 --24ygsgv57ix6tldz Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 27, 2020 at 08:52:38PM +1200, Fehmi Noyan ISI via freebsd-hacke= rs wrote: >=20 >=20 > > On 23/05/2020, at 11:47 PM, Yuri Pankov wrote: > >=20 > > Fehmi Noyan ISI via freebsd-hackers wrote: > >>> On 23/05/2020, at 11:21 PM, Yuri Pankov wrote: > >>>=20 > >>> Fehmi Noyan ISI via freebsd-hackers wrote: > >>>> Hiya > >>>> Apparently, after we switched from GNU diff to BSD diff, the -N flag= no longer assumes absent files as empty. > >>>> There is a bug report about GNU diff compatibility but when I look a= t diff(1) man page, I see that not treating absent files as empty is intent= ional rather than a missing functionality. > >>>> If this is not the case, I can work on patch to match to GNU diff be= haviour, otherwise, this bug report can be closed I think. > >>>> What=E2=80=99s your take on this? > >>>> -N --new-file > >>>> If a file is found in only one directory, act as if it was found > >>>> in the other directory too but was of zero size. > >>>> man for GNU diff > >>>> -N, --new-file > >>>> treat absent files as empty > >>>=20 > >>> I think both descriptions say the same, i.e. "zero size" =3D=3D "empt= y=E2=80=9D? > >> Maybe it=E2=80=99s my interpretation, but if you do not supply the sec= ond argument to diff(1), it complains > >> $ echo =E2=80=9Ctest=E2=80=9D > a.txt > >> $ diff -N a.txt nofile > >> diff: nofile: No such file or directory > >> $ > >> GNU diff assumes an empty file for the missing second file and makes t= he comparison > >> $ echo =E2=80=9Ctest=E2=80=9D > a.txt > >> $ diff -N a.txt nofile > >> 1d0 > >> < test > >> $ > >=20 > > I must admit that I never used -N without -r, so it's probably the only= case that needs fixing? > >=20 > > $ mkdir a b > > $ echo bar > a/foo > > $ diff -ruN a b > > diff -ruN a/foo b/foo > > --- a/foo 2020-05-23 14:44:34.525932000 +0300 > > +++ b/foo 1970-01-01 03:00:00.000000000 +0300 > > @@ -1 +0,0 @@ > > -bar > >=20 >=20 > Took me a while to reply=E2=80=A6 > With -N, GNU diff does not give an ENOENT >=20 > % echo foo > bar > % diff bar nofile.txt > diff: nofile.txt no such file or directory > % diff -N bar nofile.txt > 1d0 > < foo >=20 > Do we want BSD diff do the same, i.e. match the -N functionality of GNU d= iff? >=20 Yes we do, if you do provide a patch I would be more than happy to review a= nd apply it. Best regards, Bapt --24ygsgv57ix6tldz Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEgOTj3suS2urGXVU3Y4mL3PG3PloFAl7OLawACgkQY4mL3PG3 Ploo2Q/8DE69TH/Ly810kFweBkQsRK1Alov9CKS6UNh23N1kKrdwm7Wwn71UkZRT NdCOVAluGtmSlzVY9Upd5Y5OOlVpBezcDsM/MBAIP0gzY0qtr6sDTQsRc/82ZDhx nN+8msezJ0/SwDYwUttCFpJHqMnHNUQKzY9WBWfxM+gPpng4hxw08iwAs9aQNKKF HZfxAk1ZbPvTQj0W0cg6PH2OtocdyHdjLwaPYszlvp8fDH1+LU1cv+sdYBK9tmmn j5kuzvK0cM14gyVy8F6jfoLgfmzoEQZyt6uOQJoD9VQ49bdz7zl587UKGNfx+K7B PkcsVVTuyDtdKTIzaRIEzEl5re0NO4uFPKNzxdko4/xYQXZ4pKx7AORuxxUc6IPp gbcE/MbifrjbQLJevRG8I6ejNS+TyCHOxy79AjkZRv0u1/p1oazSZE7mL8+6kmfo Mr8BbYc8QKyhOIBWdMrgmr29U7oa+Amh04Wc4M+7CEx4uAvj+GlYypPOEQ89UHHY Ug78HbwOLiH6YASZyb6Wj2jvWs75rGSLJRuxoWMSkMPR2QA5sUgFCc9HWY2osnUX L9Ei5jCPo1JoEJ01BH3zQ4vJyNV1Sx0keEmcB36olXcgJ3kjxBJNNL9KM3HkiZM6 Jzhux4dQDm30lcHQXh373CMR0jc75uDm9XDtXt64vIJPyGB1obQ= =g0VU -----END PGP SIGNATURE----- --24ygsgv57ix6tldz--