On 13/03/2024 14:19, Douglas McIlroy wrote:
In coreutils 9.0, pr option -i (output tabification) is turned on by
default. This mistake radically complicates any further processing of the
output. Has it been fixed in later versions? (I didn't spot it in the bug
archive, but my search terms could have been wrong.)

Doug McIlroy

Hi!

Yes that is a bit surprising, but I see POSIX specifies,
that multi column output implies -e and -i.
I.e. tabs are converted to spaces on input,
and tabs are used to align output unconditionally.
I presume you're seeing this with multi column only.

For reference one can see the -i output processing with:

  $ printf '[%8s]\n' $(seq 4) | pr -2 -tT | sed 's/ /./g;s/\t/--->/g'
  [--->1]--->--->--->....[--->....3]
  [--->2]--->--->--->....[--->....4]

  $ printf '[%8s]\n' $(seq 4) | pr -2 -tT -i' ' | sed 's/ /./g;s/\t/--->/g'
  [.1].......[.....3]
  [.2].......[.....4]

  $ printf '[%8s]\n' $(seq 4) | pr -2 -tT -s' ' | sed 's/ /./g;s/\t/--->/g'
  [--->1].[--->...3]
  [--->2].[--->...4]

I suppose you can pre or post process with expand/unexpand,
but that's not ideal either. Would that suffice for you?

  $ printf '[%8s]\n' $(seq 4) | pr -2 -tT | expand -t4 | sed 's/ 
/./g;s/\t/--->/g'
  [...1]..............[.......3]
  [...2]..............[.......4]

I'm not sure what to adjust here TBH.
If we gave options to disable -e and -i, then
multi-column alignment would be more complicated I think.

thanks,
Pádraig

Reply via email to