]> git.ipfire.org Git - thirdparty/util-linux.git/commit
column: add --wrap-separator option for custom text wrapping
authorKarel Zak <kzak@redhat.com>
Mon, 15 Sep 2025 14:14:08 +0000 (16:14 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 16 Sep 2025 09:59:19 +0000 (11:59 +0200)
commit5fd9b8c95ca67e1c14002c6c2b04315049ef14ba
treeb777873b11b0a44e600618da6acbfc5dec2518eb
parent41c1dc60903803c2a4d7f286012f8e96ff06990f
column: add --wrap-separator option for custom text wrapping

Add a new --wrap-separator option that allows users to specify custom
separator characters for text wrapping within table columns. When used
with --table-wrap, the separator is replaced with newlines to enable
wrapping at specific points rather than just by column width.

The implementation:
- Processes wrap separator replacement in modify_table() after column
  wrap flags are set
- Uses scols_cell_refer_memory() for data containing embedded nulls
- Enables scols_wrapzero_nextchunk for columns with wrapping enabled
- Only applies to columns that have the wrap flag set via --table-wrap

Example usage:
  $ echo -e 'Name:Desc\nJohn:A|software|dev' | \
column --table --separator ':' \
                       --table-wrap 2 --wrap-separator '|'
  Name  Desc
  John  A
        software
        dev

Fixes: https://github.com/util-linux/util-linux/issues/3739
Signed-off-by: Karel Zak <kzak@redhat.com>
tests/expected/column/table-wrap-separator-all-columns [new file with mode: 0644]
tests/expected/column/table-wrap-separator-basic [new file with mode: 0644]
tests/expected/column/table-wrap-separator-multichar [new file with mode: 0644]
tests/expected/column/table-wrap-separator-multiple-separators [new file with mode: 0644]
tests/expected/column/table-wrap-separator-without-wrap [new file with mode: 0644]
tests/ts/column/table
text-utils/column.1.adoc
text-utils/column.c