-N works without -r in GNU diff, which is useful because it can make scripts a tiny bit simpler. this functionality got lost with the switch from GNU diff to the OpenBSD one. GNU/Linux: roman@crowbar ~ master 0 1002 0 . echo fubar > snafu roman@crowbar ~ master 0 1003 0 . diff snafu wtf diff: wtf: No such file or directory roman@crowbar ~ master 0 1004 2 . diff -N snafu wtf 1d0 < fubar FreeBSD: roman@sheeba ~ master :M 0 1003 2 . echo fubar > snafu roman@sheeba ~ master :M 0 1004 0 . diff snafu wtf diff: wtf: No such file or directory roman@sheeba ~ master :M 0 1005 2 . diff -N snafu wtf diff: wtf: No such file or directory
Is being able to use -N without -r the desired behaviour for diff(1)? From diff(1) man page, I understand that FreeBSD diff(1) requires the second file to be present in the directory where a recursive call starts but necessarily in the current working directory. FreeBSD man 1 diff -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
A patch has been submitted (no reviewers yet) https://reviews.freebsd.org/D25081
A commit references this bug: Author: bapt Date: Mon Jun 1 09:09:37 UTC 2020 New revision: 361689 URL: https://svnweb.freebsd.org/changeset/base/361689 Log: diff: restore compatibility with GNU diff regarding -N option When -N is used the missing files are treated as empty. PR: 233402 Submitted by: Fehmi Noyan Isi <fnoyanisi@yahoo.com> Reported by: Roman Neuhauser <roman@sigpipe.cz> MFC after: 3 days Differential Revision: D25081 Changes: head/usr.bin/diff/diff.c head/usr.bin/diff/tests/diff_test.sh
Fixed, thank you for reporting! sorry it took so long!
A commit references this bug: Author: bapt Date: Sat Sep 19 20:15:52 UTC 2020 New revision: 365914 URL: https://svnweb.freebsd.org/changeset/base/365914 Log: MFC r361688-r361690, r365041 r361688: Restore compatibility with GNU diff regarding --label Various options to "diff(1)" show filenames, and traditionally make use of the "--label" parameter, if set. Restore this behaviour in BSD diff. While here add a regression test PR: 244533 Submitted by: Jamie Landeg-Jones <jamie@catflap.org> r361689: diff: restore compatibility with GNU diff regarding -N option When -N is used the missing files are treated as empty. PR: 233402 Submitted by: Fehmi Noyan Isi <fnoyanisi@yahoo.com> Reported by: Roman Neuhauser <roman@sigpipe.cz> Differential Revision: D25081 r361690: Document long version of -b option PR: 234195 Submitted by: Fehmi Noyan Isi <fnoyanisi@yahoo.com> Reported by: Andras Farkas <deepbluemistake@gmail.com> r365041: diff: always properly kill pr(1) When diff is invoked with -l it will spawn the pr(1) program. In some circumpstances the pr(1) was not properly killed when diff program exits. Submitted by: Bret Ketchum Differential Revision: https://reviews.freebsd.org/D26232 Changes: _U stable/12/ stable/12/usr.bin/diff/diff.1 stable/12/usr.bin/diff/diff.c stable/12/usr.bin/diff/diffreg.c stable/12/usr.bin/diff/tests/diff_test.sh