[Bug 264559] unexpand: nonconformantly (to both POSIX and heirloom) replaces single spaces with tabs

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 08 Jun 2022 23:15:45 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=264559

            Bug ID: 264559
           Summary: unexpand: nonconformantly (to both POSIX and heirloom)
                    replaces single spaces with tabs
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: nabijaczleweli@nabijaczleweli.xyz

In many ways this report mirrors https://bugs.debian.org/1012545:

  printf 'a  b' | unexpand -t1 | cat -A
  printf 'a  b' | unexpand -t2 | cat -A
both yield
  a^I b
and
  printf 'a  b' | unexpand -t2,3 | cat -A
yields
  a^Ib

According to 4.2BSD:
  If the -a option is given, then tabs are inserted whenever they would
  compress the resultant file by replacing two or more characters.
of course, heirloom unexpand doesn't take tab lists,
but this is still wrong according to Issue 7
(quoth IEEE Std 1003.1-2017 (Revision of IEEE Std 1003.1-2008)):
  In addition to translating <blank> characters at the beginning of each
  line, translate all sequences of two or more <blank> characters
  immediately preceding a tab stop to the maximum number of <tab>
  characters followed by the minimum number of <space> characters needed
  to fill the same column positions originally filled by the translated
  <blank> characters.

The correct output for all three is, of course:
  a  b
(NetBSD and the illumos gate agree;
 coreutils is broken differently, but that's unrelated).

Best,
наб

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