Skip to content

ls: accept a leading ' in --block-size and group digits - #16961

Merged
cakebaker merged 1 commit into
uutils:mainfrom
og-orca:ls-block-size-thousands
Nov 29, 2026
Merged

cakebaker merged 1 commit into
uutils:mainfrom
og-orca:ls-block-size-thousands

Conversation

@og-orca

@og-orca og-orca commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #9084.

ls -l --block-size="'1" failed with "invalid --block-size argument". GNU ls takes the leading ' to mean "group the digits with the locale's thousands separator". du already handles this, ls didn't.

Now ls strips the ' before parsing the size and groups the numbers in the size column, the -s column and the total line. In the C locale there is no separator, so the output is unchanged.

The width of those columns used to be counted in bytes. With fr_FR the separator is U+202F, which is 3 bytes, so the columns came out too wide. I count chars there now. This only changes anything when the separator is non-ASCII.

I compared the output with GNU ls 9.12 on macOS in C, en_US.UTF-8 and fr_FR.UTF-8, with a few files of different sizes and on /usr/bin. They match. The month name in fr_FR is still different, but that is a separate thing.

Not in this PR: LS_BLOCK_SIZE="'1" / BLOCK_SIZE="'1" from the environment. I can do that in a follow-up.

I used an AI assistant for parts of this. I checked the diff and the GNU comparison myself.

@cakebaker
cakebaker merged commit 53ca8ad into uutils:main Nov 29, 2026
105 checks passed
@cakebaker

Copy link
Copy Markdown
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ls (and du) block size specification with thousands separator fails

2 participants