Repository navigation
du: support block-size suffixes and grouping - #13655
Conversation
|
GNU testsuite comparison: |
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
e32b9e0 to
ed84080
Compare
ed84080 to
3787179
Compare
|
Binary size comparison: |
3787179 to
b0f102f
Compare
|
Would you mind taking a look when convenient? Thanks! |
c15bf43 to
5c139cf
Compare
84baa46 to
da537b5
Compare
da537b5 to
84179b1
Compare
|
@sylvestre ready |
84179b1 to
bccb32b
Compare
bccb32b to
498e424
Compare
498e424 to
d0d8cb5
Compare
a043220 to
69cae44
Compare
69cae44 to
f92c17c
Compare
f92c17c to
dc98e1a
Compare
dc98e1a to
0bacf21
Compare
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
0bacf21 to
4cc9191
Compare
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
| Ok(bytes) | ||
| } else { | ||
| Ok(parse_block_size::default_block_size()) | ||
| for var in vars { |
There was a problem hiding this comment.
this duplicates parse_block_size::block_size_from_env, could you please extend it in uucore to also return the raw value instead? df/ls will need the same suffix handling
| } | ||
|
|
||
| let suffix = match chars.as_str() { | ||
| "" | "D" => unit.to_string(), |
There was a problem hiding this comment.
which input ends up with a D suffix here? please add a test for it or drop it
| } | ||
|
|
||
| /// Add the locale grouping requested by a leading apostrophe in SIZE. | ||
| fn format_block_count(blocks: u64, grouping: bool) -> Vec<u8> { |
There was a problem hiding this comment.
almost the same as apply_grouping in numfmt, could it be moved to uucore and shared?
| return digits.into_bytes(); | ||
| } | ||
|
|
||
| let separator = if get_numeric_locale().1 == UEncoding::Ascii && separator == "\u{202f}" { |
There was a problem hiding this comment.
why this special case for U+202F only?
please document the why, or handle it in uucore for all non-UTF-8 locales
| } | ||
|
|
||
| #[test] | ||
| fn test_du_block_size_locale_grouping() { |
There was a problem hiding this comment.
this is probably the wasm failure, please add #[cfg_attr(wasi_runner, ignore = "WASI: locale env vars not propagated")] like the other locale tests
|
sorry for the latency |
4cc9191 to
b06672f
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Active moderate issues remain in parse_size_u64: decimal D aliases are mislabelled as binary and apostrophe-prefixed parse errors report incorrect caret spans.
7 open issues
The env-var search returns immediately on the first present variable, even if its value is… Offset diagnostic spans for the leading apostrophe · New Preserve decimal semantics for D suffix aliases · New TheOption<String>stored inSizeFormat::BlockSizenow implicitly carries two concerns: (a)… Two concrete hotspots here for large directory traversals: (1)… The new env-var parsing/precedence behavior isn’t covered for failure cases. Please add a test that… TheOption<String>stored inSizeFormat::BlockSizenow implicitly carries two concerns: (a)…
Review effort: Lite
| let parsed = s.strip_prefix('\'').unwrap_or(s); | ||
| parse_size_u64(parsed) |
| let suffix = match chars.as_str() { | ||
| "" | "D" => unit.to_string(), | ||
| "B" if unit == 'K' => "kB".to_string(), | ||
| suffix => format!("{unit}{suffix}"), |


Fixes #13605.
Preserve unit suffixes for block sizes specified without a numeric prefix, including values from
DU_BLOCK_SIZE,BLOCK_SIZE, andBLOCKSIZE. Numeric block sizes keep their existing output format.Should make test tests/du/block-size.sh pass