Skip to content

feat: support GNU ls -f as shorthand for -a -U - #1232

Open
MsfPablo wants to merge 1 commit into
lsd-rs:mainfrom
MsfPablo:feat/gnu-ls-f-flag
Open

feat: support GNU ls -f as shorthand for -a -U#1232
MsfPablo wants to merge 1 commit into
lsd-rs:mainfrom
MsfPablo:feat/gnu-ls-f-flag

Conversation

@MsfPablo

Copy link
Copy Markdown

Closes #1181.

GNU ls accepts -f, which lists entries in directory order (no sorting) and does not hide dotfiles. lsd rejected it outright:

$ lsd -f
error: unexpected argument '-f' found

This breaks alias ls=lsd whenever a script or tool emits ls -f.

Change

Adds -f as a short-only flag meaning "do not sort, and show hidden entries" — equivalent to -a -U:

  • src/app.rs: new no_sort_all arg with the same overrides_with_all list as -U, so an explicit sort flag given later still wins (lsd -f -t sorts by time, lsd -t -f does not sort), matching GNU's last-one-wins behaviour.
  • src/flags/display.rs: -f implies Display::All (-A still takes precedence, as it does over -a).
  • src/flags/sorting.rs: -f implies SortColumn::None.
  • doc/lsd.md: documented.

Scope kept to what the issue asks: GNU's -f also disables --color and -l, but that felt out of scope and unhelpful for lsd, so it is not replicated. Happy to add it if maintainers prefer full parity.

Tests

Unit tests for Display::from_cli and SortColumn::from_cli (including both -f -t / -t -f orderings) plus an integration test asserting -f lists hidden entries.

$ cargo test
   ... 394 passed; 0 failed        (unit)
   ... 43 passed; 1 failed         (integration)
$ cargo fmt --check   # clean
$ cargo clippy --all-targets   # 7 warnings, identical to the count on unmodified master

The single integration failure is test_date_custom_format_supports_nanos_with_length, which fails identically on unmodified master in my environment (locale uses , as the decimal separator) — pre-existing and unrelated; see #1227 / #1230.


Disclosure: this patch was written with AI assistance (Claude). I reviewed the diff and ran the full verification above locally.

GNU ls accepts -f to list entries in directory order without sorting and
without hiding dotfiles. lsd rejected it with 'unexpected argument', which
breaks 'alias ls=lsd' for scripts and tools that emit 'ls -f'.

Closes lsd-rs#1181
@MsfPablo
MsfPablo requested a review from zwpaper as a code owner August 11, 2026 13:32
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.

lsd: unexpected argument '-f' found

1 participant