feat: support GNU ls -f as shorthand for -a -U - #1232
Open
MsfPablo wants to merge 1 commit into
Open
Conversation
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
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.
Closes #1181.
GNU
lsaccepts-f, which lists entries in directory order (no sorting) and does not hide dotfiles.lsdrejected it outright:This breaks
alias ls=lsdwhenever a script or tool emitsls -f.Change
Adds
-fas a short-only flag meaning "do not sort, and show hidden entries" — equivalent to-a -U:src/app.rs: newno_sort_allarg with the sameoverrides_with_alllist as-U, so an explicit sort flag given later still wins (lsd -f -tsorts by time,lsd -t -fdoes not sort), matching GNU's last-one-wins behaviour.src/flags/display.rs:-fimpliesDisplay::All(-Astill takes precedence, as it does over-a).src/flags/sorting.rs:-fimpliesSortColumn::None.doc/lsd.md: documented.Scope kept to what the issue asks: GNU's
-falso disables--colorand-l, but that felt out of scope and unhelpful forlsd, so it is not replicated. Happy to add it if maintainers prefer full parity.Tests
Unit tests for
Display::from_cliandSortColumn::from_cli(including both-f -t/-t -forderings) plus an integration test asserting-flists hidden entries.The single integration failure is
test_date_custom_format_supports_nanos_with_length, which fails identically on unmodifiedmasterin 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.