Some comments about /usr/bin/diff

Andrea Venturoli ml at netfence.it
Sun Dec 22 19:19:31 UTC 2019


Hello.

(I hope this is not considered ranting; I'm not used to it and I'm 
trying to be constructive...)



I recently upgraded a box from 11.3 to 12.1 and I see diff has changed a 
lot: IIUIC on 11.3 I had GNU diff (possibly from 
/usr/src/contrib/diff?), while on 12.1 I have a different version (I 
believe it's BSD diff, from /usr/src/usr.bin/diff).
I don't believe this change comes from some local settings of mine, but 
I didn't see it mentioned in the release notes (either for 12.0 or 12.1).
I think I know the reasons behind this (licenses) and I understand it: 
only, if I had known, I wouldn't have lost almost one day after a script 
that used to work before.



But lets move away from this...
11.3's diff used to have a -y/--side-by-side option (which showed the 
two file on two columns); this is now gone.
Shouldn't this be considered a regression?



Finally, in a task of mine I often have to "diff -rq" two directories 
which have ~75000 files; those files are usually very similar, with a 
only a few lines differing. Some of them have up to 25M lines.

11.3 takes under 7 minutes to perform the task, while I had to interupt 
12.1 after a few hours and I have no idea how far it got.

After some "gdb"ugging, I see 12.1 gets stuck when it arrives at a big 
multi-million lines file: my guess is that 11.3 sees one line is 
different, outputs the result and moves on to the next file, while 12.1 
will (try to) compute the full difference as if "-q" was not given.
Persnoally, I would call this a bug.



Of course an easy solution is to install textproc/diffutils and change 
"diff" to "gdiff".



I know the rule: if you don't like this, go ahead and submit patches, 
but I'm not up to it (at least not now).
I'm just hoping that reading this will ease it for others who might fall 
in the same pitfall.



  bye
	av.


More information about the freebsd-questions mailing list