Repository navigation
ls: fix //DIRED-OPTIONS// printing the wrong quoting-style name - #14847
Merged
Merged
Conversation
sylvestre
reviewed
Sep 24, 2026
| Ok(()) | ||
| } | ||
|
|
||
| /// The canonical `--quoting-style` name for the `//DIRED-OPTIONS//` trailer. |
Contributor
There was a problem hiding this comment.
nobody will read such a long comment :) could you please make it one or two lines?
sylvestre
reviewed
Sep 24, 2026
| .stdout_contains("//DIRED-OPTIONS// --quoting-style"); | ||
| } | ||
|
|
||
| // Regression test for issue #14775: //DIRED-OPTIONS// must report the |
Contributor
There was a problem hiding this comment.
please make it shorter, the issue link is enough
Collaborator
|
This PR conflicts with #14849, which heavily refactors quoting mechanisms. I'd advise to refrain from merging it for now |
alter
force-pushed
the
fix/dired-quoting-style-name
branch
from
September 27, 2026 21:59
a40ef98 to
ee81d2e
Compare
Contributor
|
Thanks for your PR |
Collaborator
|
@sylvestre Can I take over the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #14775
What
GNU
ls --diredends its output with//DIRED-OPTIONS// --quoting-style=<name>, where<name>is the canonical name of the quoting style in effect (literal, shell, shell-always, shell-escape, shell-escape-always, c, escape, locale, clocale). uutils was printing theDisplayform of the internalQuotingStyleenum instead, which gets most of these wrong: several distinct style names collapse onto the same enum shape (c,escapeandclocaleall reduce toQuotingStyle::C;literalandlocaleboth reduce toQuotingStyle::Literal), and theDisplayimpl also appends a-show-control/-always-quotesuffix that the--diredtrailer never uses (those describe separatelsoptions, not part of the quoting-style name).Why
DisplayforQuotingStyleis used elsewhere and reconstructs a name purely from the enum's own fields, so it can't tellcfromescapefromclocale, orliteralfromlocale. The extra bit needed to disambiguate the locale-aware pair already exists onConfigaslocale_quoting: Option<LocaleQuoting>(set during option parsing), it just wasn't being consulted for the dired trailer.Fix
Added
dired_quoting_style_name()insrc/uu/ls/src/dired.rs, used only for the//DIRED-OPTIONS//line. It checksconfig.locale_quotingfirst (disambiguateslocale/clocale), then matches onconfig.quoting_style's own fields directly: theQuotesfield on theCvariant already distinguishesc(Quotes::Double) fromescape(Quotes::None), and the(escape, always_quote)fields onShellmap directly to the four shell style names, with noshow_control/-show-controlsuffix.Testing
Added
test_ls_dired_quoting_style_nametotests/by-util/test_ls.rs, covering all 9--quoting-style=<name>values plus the-N/-Q/-bshort flags, checking the exact//DIRED-OPTIONS//line against the canonical GNU name from the issue's own table. Confirmed it fails against unmodifieddired.rs(e.g.--quoting-style=cprints--quoting-style=C) and passes after the fix.cargo test --features ls(dired + quoting-style tests): 21/21 dired tests and 7/7 dired module unit tests passing, no regressions.cargo clippy -p uu_ls --all-targets -- -D warnings: clean.cargo fmt --check: clean.Also manually verified all 9 styles plus the 3 short flags against a built binary, matching the issue's own reproduction table exactly.