ls: allow --sort, --format, --time, --block-size without '=' - #13308
Closed
koopatroopa787 wants to merge 1 commit into
Closed
ls: allow --sort, --format, --time, --block-size without '='#13308koopatroopa787 wants to merge 1 commit into
koopatroopa787 wants to merge 1 commit into
Conversation
These four options used .require_equals(true) in clap, which forced users to write --sort=name instead of the GNU-compatible --sort name. GNU ls accepts both forms, so this was a regression. The optional-value flags --color, --classify, and --hyperlink keep .require_equals(true) because they have num_args(0..=1) and a default_missing_value — without the equals sign clap cannot tell whether the next word is the option's value or a file operand. --sort, --format, --time, and --block-size always require exactly one argument, so the space-separated form is unambiguous and matches GNU. Adds four regression tests (one per fixed option). Fixes uutils#13280
|
GNU testsuite comparison: |
Contributor
|
Duplicate of #13281 |
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.
Summary
ls --sort name /fails with:The four options
--sort,--format,--time, and--block-sizehad.require_equals(true)in their clap definition, which forced the--opt=valuesyntax and rejected the space-separated--opt valueform. GNU ls accepts both forms.
Fix
Remove
.require_equals(true)from the four affected options.The optional-value flags
--color,--classify, and--hyperlinkarenot changed — they use
num_args(0..=1)with adefault_missing_value,and they legitimately need
require_equalsso clap can tell whetherthe next word is the option's value or a file operand.
--sort,--format,--time, and--block-sizealways consumeexactly one value, so the space-separated form is unambiguous.
Changes
src/uu/ls/src/ls.rs: remove.require_equals(true)fromFORMAT,TIME,SORT, andsize::BLOCK_SIZE.tests/by-util/test_ls.rs: four regression tests, one per option.Fixes #13280