Repository navigation
sort: use os_string_from_vec for --files0-from names - #12773
Conversation
|
GNU testsuite comparison: |
Merging this PR will not alter performance
Comparing Footnotes
|
RenjiSann
left a comment
There was a problem hiding this comment.
Please fix the merge conflicts, otherwise, good job :D
The same panic was fixed by #11593 (merged 2026-06-30, Fixes #9696), which landed the equivalent |
|
I like this one better because it uses |
`sort --files0-from=F` decoded each NUL-separated filename with `str::from_utf8(&line).expect(...)`, aborting on any non-UTF-8 byte — Linux filenames are arbitrary byte strings. Carry the name as an `OsString` built from the raw bytes (via `uucore::os_string_from_vec`) and do the "-"/empty checks on the bytes, so a non-UTF-8 name flows into the normal open-failure path (exit 2) like GNU instead of aborting.
2e84ad1 to
42e69fd
Compare
|
Thanks @RenjiSann! I've rebased onto main and resolved the conflicts. |
|
Thanks ! |
Follow-up to #11593.
#11593 fixed the
--files0-fromnon-UTF-8 panic by decoding the raw bytes inline (#[cfg(unix)] OsStr::from_bytes/#[cfg(not(unix))] from_utf8_lossy). This replaces that inline reimplementation with the shareduucore::os_string_from_vechelper, so the byte→OsStringconversion has a single source of truth rather than duplicated (and already slightly diverging) logic. The-/empty-name checks now run on the raw bytes.Behavior is unchanged on Unix (both are lossless); the Unix-gated regression test (a non-UTF-8 name →
cannot read, exit 2) still passes.