[Bug 278988] diff -B -q: unintuitive or incorrect?

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 14 May 2024 20:39:05 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278988

            Bug ID: 278988
           Summary: diff -B -q: unintuitive or incorrect?
           Product: Base System
           Version: 14.0-STABLE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: dhekir@gmail.com

I stumbled upon a very unintuitive behavior of diff: when option -q is used, -B
is ignored, unless it is also accompanied by -b, as in the following examples

# create test files: one containing a single newline, another containing 2
newlines
$ echo "" > a
$ echo -e "\n" > b

$ diff a b -B # ok: no diff reported
$ diff a b -B -q # weird: -B seems ignored, diff reported (GNU diff does not
report it)
$ diff a b -b # ok: -b only ignores spaces, not entire lines
$ diff a b -b -q # ok: the diff remains, -q does not affect it
$ diff a b -B -b -q # ok: this time, -B was taken into account

So, we have:

1. -B works on its own;
2. when -B -q is used, -B seems ignored;
3. -b on its own does not suffice to remove the diff in these files
4. -B -b -q works (no diff), but since -b is irrelevant without -q, this seems
like a bug.

In GNU diff, `diff a b -B -q` behaves as what I consider "expected": the files
are considered equal.

If this is intended behavior, the documentation needs to mention it.

Bug #252515 is similar to this one (it mentioned `-w`, while this one mentions
`-B`).

-- 
You are receiving this mail because:
You are the assignee for the bug.