From owner-freebsd-hackers@freebsd.org Thu May 28 09:21:24 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 288B232BAAE for ; Thu, 28 May 2020 09:21:24 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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 49Xhyr0K6Pz4GNC; Thu, 28 May 2020 09:21:24 +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 E6E3022FD3; Thu, 28 May 2020 09:21:23 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from mail.nours.eu (etoilebsd.net [IPv6:2001:41d0:8:db4c::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ivaldir.etoilebsd.net (Postfix) with ESMTPSA id 2DE2BD7253; Thu, 28 May 2020 11:21:21 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Thu, 28 May 2020 11:21:16 +0200 From: Baptiste Daroussin To: bsd-lists@bsdforge.com Cc: Yuri Pankov , freebsd-hackers@freebsd.org, Fehmi Noyan ISI Subject: Re: diff(1) -N behaviour - Bug 233402 In-Reply-To: <3df104a8139d5252b3426ae1600bfc86@udns.ultimatedns.net> References: <3df104a8139d5252b3426ae1600bfc86@udns.ultimatedns.net> User-Agent: Roundcube Webmail/1.4.4 Message-ID: X-Sender: bapt@FreeBSD.org 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: Thu, 28 May 2020 09:21:24 -0000 On 2020-05-28 08:26, Chris wrote: > On Wed, 27 May 2020 11:06:52 +0200 Baptiste Daroussin bapt@FreeBSD.org > said > >> On Wed, May 27, 2020 at 08:52:38PM +1200, Fehmi Noyan ISI via >> freebsd-hackers >> wrote: >> > > > > On 23/05/2020, at 11:47 PM, Yuri Pankov wrote: >> > > > > Fehmi Noyan ISI via freebsd-hackers wrote: >> > >>> On 23/05/2020, at 11:21 PM, Yuri Pankov wrote: >> > >>> > >>> 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 at >> > diff(1) man page, I see that not treating absent files as empty is intentional >> > rather than a missing functionality. >> > >>>> If this is not the case, I can work on patch to match to GNU diff >> > behaviour, otherwise, this bug report can be closed I think. >> > >>>> What’s 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 >> > >>> > >>> I think both descriptions say the same, i.e. "zero size" == "empty”? >> > >> Maybe it’s my interpretation, but if you do not supply the second >> > argument to diff(1), it complains >> > >> $ echo “test” > 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 the >> > comparison >> > >> $ echo “test” > a.txt >> > >> $ diff -N a.txt nofile >> > >> 1d0 >> > >> < test >> > >> $ >> > > > > I must admit that I never used -N without -r, so it's probably the only >> > case that needs fixing? >> > > > > $ 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 >> > > > > Took me a while to reply… >> > With -N, GNU diff does not give an ENOENT >> > > % echo foo > bar >> > % diff bar nofile.txt >> > diff: nofile.txt no such file or directory >> > % diff -N bar nofile.txt >> > 1d0 >> > < foo >> > > Do we want BSD diff do the same, i.e. match the -N functionality of GNU >> > diff? >> > Yes we do, > Why? If someone wants a GNU diff. Can't they simply install it? If > FreeBSD diff is to become like GNU diff, what's the point of having > a FreeBSD version. > Apologies in advance if I'm missing anything here. > Because When I switched from GNU diff to BSD diff recently, the intent was to be mostly compatible with GNU diff (the one we had for very long, not necessary the very latest version if it) it has been requested by many users to avoid breakage in most script and usage of diff people were having for a long time. while what has been committed is not 100% compatible it is very close, and there is a file that documents what is missing from this implementation. Now back to the -N the behaviour Fehmi is proposing to fix is a bug in what I did implement the intent as always been to get the behaviour he describes not the one we currently have. Side note: the motivation for switching from GNU diff to BSD diff in base is the same as for the rest of the removal of the GNU components in base: we cannot get any update because newer version are in GPLv3). Best regards, Bapt