diffutils: -iBZ fails to ignore trailing ASCII spaces on Unix-encoded files in Cygwin

Bloodaxe bloodaxe@gmail.com
Wed Sep 23 04:42:03 GMT 2026


Quick update regarding this issue:

I tested setting the locale explicitly and found that the failure occurs
specifically when 'LANG' is unset or set to 'C':

- LANG unset: 'diff -iBZ' fails with exit status 1.
- LANG=C: 'diff -iBZ' fails with exit status 1.
- LANG=en_US.UTF-8: 'diff -iBZ' succeeds with exit status 0 (NO REPRO).

Note that '-iBZ' worked as expected in earlier Cygwin releases without
needing 'LANG' set, so this represents a regression in diffutils 3.12 (or
Cygwin's default locale initialization) where boundary-scanning logic (-Z)
now requires an explicitly initialized UTF-8 locale environment to process
trailing ASCII spaces (0x20) before 0x0A.


On Wed, Sep 23, 2026, 12:18 AM Bloodaxe <bloodaxe@gmail.com> wrote:

> I have identified an issue in GNU diffutils 3.12 under Cygwin where
> combining flags '-iBZ' (or running them separately as '-i -B -Z') fails to
> ignore trailing standard ASCII spaces (0x20) on pure POSIX/Unix-encoded
> files (0x0A line endings), whereas '-iBb' succeeds as expected.
>
> Below is the output from a minimal reproduction script verifying the raw
> byte layouts and flag behavior:
>
> ==================================================
> 1. ENVIRONMENT DETAILS
> ==================================================
> CYGWIN_NT-10.0-19045 LOCAL-HOST 3.6.10-1.x86_64 2026-07-13 20:20 UTC
> x86_64 Cygwin
> LANG: not set
> diff (GNU diffutils) 3.12
>
> ==================================================
> 2. RAW BYTE HEX DUMPS
> ==================================================
> FILE 1 (with trailing spaces):
> 0000000  20  20  20  20  20  34  2d  2d  7c  20  20  20  2b  20  20  20
>                               4   -   -   |               +
> 0000020  2b  20  20  20  2b  20  20  20  2b  20  20  20  2b  20  20  20
>               +               +               +               +
> 0000040  2b  20  20  20  7c  2d  2d  34  20  20  20  20  20  20  20  20
>               +               |   -   -   4
> 0000060  20  7c  20  20  20  20  20  20  0a
>                   |                          \n
> 0000071
>
> FILE 2 (without trailing spaces):
> 0000000  20  20  20  20  20  34  2d  2d  7c  20  20  20  2b  20  20  20
>                               4   -   -   |               +
> 0000020  2b  20  20  20  2b  20  20  20  2b  20  20  20  2b  20  20  20
>               +               +               +               +
> 0000040  2b  20  20  20  7c  2d  2d  34  20  20  20  20  20  20  20  20
>               +               |   -   -   4
> 0000060  20  7c  0a
>                   |  \n
> 0000063
>
> ==================================================
> 3. RUNNING DIFF TESTS
> ==================================================
> --> Test A: Combined '-iBZ'
> 1c1
> <      4--|   +   +   +   +   +   +   |--4         |
> ---
> >      4--|   +   +   +   +   +   +   |--4         |
> Exit Code: 1
>
> --> Test B: Separated '-i -B -Z'
> 1c1
> <      4--|   +   +   +   +   +   +   |--4         |
> ---
> >      4--|   +   +   +   +   +   +   |--4         |
> Exit Code: 1
>
> --> Test C: Combined '-iBb' (Reference)
> Exit Code: 0
>
> ==================================================
> 4. EXPECTED VS. ACTUAL BEHAVIOR
> ==================================================
> Expected: Since both files use clean POSIX line feeds (0x0A) and standard
> ASCII spaces (0x20), '-Z' ('--ignore-trailing-space') should ignore the
> trailing 0x20 bytes after '|' and evaluate exit code 0.
> Actual: Both '-iBZ' and '-i -B -Z' flag a difference on line 1 and exit
> with code 1. '-iBb' correctly ignores the trailing whitespace and returns
> exit code 0.
>
>
>


More information about the Cygwin mailing list