Skip to content

ls: validate --block-size before -h/--si overrides it - #16025

Open
Logic769 wants to merge 4 commits into
uutils:mainfrom
Logic769:ls-validate-block-size-order
Open

Logic769 wants to merge 4 commits into
uutils:mainfrom
Logic769:ls-validate-block-size-order

Conversation

@Logic769

Copy link
Copy Markdown
Contributor

ls --block-size=0 --si printed the listing and exited 0, because --si (or -h) appearing after --block-size made clap drop the block-size value before it was validated. GNU validates the argument as it is parsed, regardless of option order:

$ ls --block-size=0 --si a.txt
ls: invalid --block-size argument '0'

Validate every command-line --block-size value up front, so an invalid size is rejected even when a later -h/--si changes the display format. The existing last-one-wins behaviour between --block-size and -h/--si is unchanged.

Test: tests/by-util/test_ls.rs::test_ls_invalid_block_size (new cases for --block-size=0 --si and --block-size=invalid --human-readable).

Closes #16008

@Logic769
Logic769 force-pushed the ls-validate-block-size-order branch 2 times, most recently from fe5ed6c to c4dc7a7 Compare October 30, 2026 13:02
Comment thread src/uu/ls/src/ls.rs Resolved
Comment thread src/uu/ls/src/ls.rs Resolved
Comment thread tests/by-util/test_ls.rs Resolved
@sylvestre
sylvestre force-pushed the ls-validate-block-size-order branch from 22410bd to 183c419 Compare November 3, 2026 00:54
@sylvestre

Copy link
Copy Markdown
Contributor

clippy is sad on 7 jobs :)

@sylvestre

Copy link
Copy Markdown
Contributor

clippy is sad :), and a bunch of jobs are failing

@Logic769
Logic769 force-pushed the ls-validate-block-size-order branch from 183c419 to f7b9531 Compare November 3, 2026 15:43
@codspeed

codspeed Bot commented Nov 3, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 3.46%

3 warnings

⚠️ 8 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 1 benchmark with a significant change ran on different hardware

Its base and head results were measured on machines with a different CPU, core count or memory, so the change might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚠️ 1 benchmark with a significant change ran in a different software environment

Its base and head results were measured with a different OS or toolchain, such as compiler, runtime or library versions, so the change might come from this difference rather than from the code. Open the benchmark to see what changed.

See affected benchmarks

❌ 1 regressed benchmark
✅ 15 untouched benchmarks
⏩ 456 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ CPU Simulation ls_recursive_balanced_tree[(6, 4, 15)] 96.9 ms 100.4 ms -3.46%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing Logic769:ls-validate-block-size-order (f7b9531) with main (c5ce288)2

Open in CodSpeed

Footnotes

  1. 456 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (36a00ef) during the generation of this report, so c5ce288 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

This branch has not been deployed

No deployments
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: --block-size=0 is accepted when --si comes later

2 participants