]> git.ipfire.org Git - thirdparty/coreutils.git/commit
ls: exclude newline from consideration in line width
authorPádraig Brady <P@draigBrady.com>
Mon, 4 May 2026 14:34:32 +0000 (15:34 +0100)
committerPádraig Brady <P@draigBrady.com>
Mon, 4 May 2026 22:58:12 +0000 (23:58 +0100)
commite63681148123216697701ec9f9750a4ccf0c6671
tree5633bca2d02b3448b58f8fdc0fc2c20b1715aa4d
parent13b8c11275669ebdf8cdac714eec8fb9566a4237
ls: exclude newline from consideration in line width

* src/ls.c (calculate_columns): Treat width as inclusive max.
(print_with_separator): Likewise.  Also handle commas explicitly,
since they're not catered for by an implicit newline in the count.
* tests/ls/w-option.sh: Adjust exact-fit column tests.
Note this change also makes the existing `ls -w4 -x -T0 a b` test
behave consistently with other output width limits.
Also add the test case from:
https://github.com/coreutils/coreutils/pull/213
* tests/ls/m-option.sh: Add a test case to ensure appropriate
wrapping when trailing comma at the line limit.
* NEWS: Mention the change in behavior.
NEWS
src/ls.c
tests/ls/m-option.sh
tests/ls/w-option.sh