Skip to content

ls: resolve --dired by argument position - #14590

Open
ChihweiLHBird wants to merge 2 commits into
uutils:mainfrom
ChihweiLHBird:zhiwei/fix-ls-dired-last-wins
Open

ChihweiLHBird wants to merge 2 commits into
uutils:mainfrom
ChihweiLHBird:zhiwei/fix-ls-dired-last-wins

Conversation

@ChihweiLHBird

Copy link
Copy Markdown
Contributor

Summary

--dired forced long format no matter what followed it. GNU treats -D like -g, -o and -n that a later -C, -x, -m or --format= wins, and dired output is emitted only when the final format is long and no --hyperlink comes after the last -D.

Before this PR, uutils could not see where -D was. clap's overrides_with with --format= and --hyperlink deleted the flag from the matches, and the argv scan added to work around that (is_dired_arg_present) also matched files literally named -D.

Behaviour Comparing to GNU

One file a, stdout a pipe

Command Before After (= GNU 9.10)
ls --dired -C a long listing a
ls --dired -C --zero a error, exit 2 a\0
ls --dired --hyperlink=never a long, no //DIRED// long + //DIRED//
ls -CD --hyperlink a columns, hyperlinked long, hyperlinked
ls -lD --format=vertical -l a long, no //DIRED// long + //DIRED//

One file literally named -D, stdout a pipe

Command Before After (= GNU 9.10)
ls -- -D long listing -D
ls --zero -- -D long listing, NUL-terminated -D\0

Files aa and bb, bb accessed more recently, stdout a pipe

Command Before After (= GNU 9.10)
ls --dired -C -u aa bb long + //DIRED//, name order bb aa (atime order)

One file a b, stdout a terminal

Command Before After (= GNU 9.10)
ls --dired 'a b' a b, --quoting-style=literal 'a b', --quoting-style=shell-escape

@ChihweiLHBird
ChihweiLHBird marked this pull request as draft September 16, 2026 01:04
@ChihweiLHBird
ChihweiLHBird marked this pull request as ready for review September 16, 2026 01:05
@ChihweiLHBird
ChihweiLHBird force-pushed the zhiwei/fix-ls-dired-last-wins branch 2 times, most recently from 19c5783 to 9791483 Compare September 16, 2026 01:25
@github-actions

github-actions Bot commented Sep 16, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/retry (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/date/resolution (passes in this run but fails in the 'main' branch)

@ChihweiLHBird
ChihweiLHBird force-pushed the zhiwei/fix-ls-dired-last-wins branch from 9791483 to 0cbd455 Compare September 16, 2026 15:42
Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me>
Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me>
@ChihweiLHBird
ChihweiLHBird force-pushed the zhiwei/fix-ls-dired-last-wins branch from 0cbd455 to 335e70b Compare September 17, 2026 02:29
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.

1 participant