Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 May 2020 11:38:31 +1200
From:      Fehmi Noyan ISI <fnoyanisi@yahoo.com>
To:        Yuri Pankov <ypankov@fastmail.com>
Cc:        Baptiste Daroussin <bapt@FreeBSD.org>, freebsd-hackers@freebsd.org
Subject:   Re: diff(1) -N behaviour - Bug 233402
Message-ID:  <42477983-D45B-4068-8949-15E4026C0857@yahoo.com>
In-Reply-To: <b4385df3-5698-03a2-256d-d77b1a8a91fb@fastmail.com>
References:  <B380BAF4-2343-4A22-A26D-13437ECC00C2.ref@yahoo.com> <B380BAF4-2343-4A22-A26D-13437ECC00C2@yahoo.com> <94a82a22-b5c9-b797-30cc-0242f6da1c8a@fastmail.com> <4ADEBC26-0F93-45C1-B775-E6E33E95FDC1@yahoo.com> <efe1c596-f99e-5e1e-3c1a-0e4af38e3464@fastmail.com> <0E0FB885-5D64-41F1-9A8B-8CEDB5884762@yahoo.com> <20200527090652.dubjpd2y2n5yfbta@ivaldir.net> <AFA8A27C-D6DC-4B45-9FDC-9D396EE7A268@yahoo.com> <b4385df3-5698-03a2-256d-d77b1a8a91fb@fastmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help


> On 27/05/2020, at 9:52 PM, Yuri Pankov <ypankov@fastmail.com> wrote:
>=20
> Fehmi Noyan ISI via freebsd-hackers wrote:
>>> On 27/05/2020, at 9:06 PM, Baptiste Daroussin <bapt@FreeBSD.org> =
wrote:
>>>=20
>>> On Wed, May 27, 2020 at 08:52:38PM +1200, Fehmi Noyan ISI via =
freebsd-hackers wrote:
>>>>=20
>>>>=20
>>>>> On 23/05/2020, at 11:47 PM, Yuri Pankov <ypankov@fastmail.com> =
wrote:
>>>>>=20
>>>>> Fehmi Noyan ISI via freebsd-hackers wrote:
>>>>>>> On 23/05/2020, at 11:21 PM, Yuri Pankov <ypankov@fastmail.com> =
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 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=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 =
"empty=E2=80=9D?
>>>>>> Maybe it=E2=80=99s my interpretation, but if you do not supply =
the second 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 the 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 diff?
>>>>=20
>>> Yes we do, if you do provide a patch I would be more than happy to =
review and
>>> apply it.
>>>=20
>>> Best regards,
>>> Bapt
>> Cheers=E2=80=A6
>> I will be working on it and update bug 233402
>=20
> Great!  I wasn't discouraging you, rather trying to understand what =
case exactly we are talking about.  Also, I think the -N option =
description in the man page should look more like GNU's one, as =
currently (I think) it implies that -r is used and we are comparing =
directories recursively.
> _______________________________________________
>=20

Yes, the BSD diff.1 man page also needs updating since the current =
wording implies that diff(1) does not treat missing files as empty =
unless it is found in any one of the directories. GNU diff=E2=80=99s =
approach here is more loose I think.

Fehmi=20




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?42477983-D45B-4068-8949-15E4026C0857>