Dear Maintainer,
printf 'a b' | unexpand -t1 | cat -A
printf 'a b' | unexpand -t2,3 | cat -A
both yield
a^I^Ib
and
printf 'a b' | unexpand -t2 | cat -A
yields
a^I b
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;
FreeBSD is broken even more, but that's unrelated).
Best,
наб