ls: Implement --zero flag. (#2929)#3746
Merged
sylvestre merged 4 commits intouutils:mainfrom Jul 31, 2022
Merged
Conversation
Contributor
|
Cool for a first contrib. |
4f32e99 to
fe791ce
Compare
Contributor
Author
|
Thanks, I suppose this issue is caused by Windows filesystem not supporting newline in filenames, I updated the test to only run with the |
sylvestre
reviewed
Jul 27, 2022
Contributor
|
Well done: |
Collaborator
tertsdiepraam
left a comment
There was a problem hiding this comment.
Cool! Nice work on all the edge cases.
This flag can be used to provide a easy machine parseable output from ls, as discussed in the GNU bug report https://debbugs.gnu.org/cgi/bugreport.cgi?bug=49716. There are some peculiarities with this flag: - Current implementation of GNU ls of the `--zero` flag implies some other flags. Those can be overridden by setting those flags after `--zero` in the command line. - This flag is not compatible with `--dired`. This patch is not 100% compliant with GNU ls: GNU ls `--zero` will fail if `--dired` and `-l` are set, while with this patch only `--dired` is needed for the command to fail. We also add `--dired` flag to the parser, with no additional behaviour change. Testing done: ``` $ bash util/build-gnu.sh [...] $ bash util/run-gnu-test.sh tests/ls/zero-option.sh [...] PASS: tests/ls/zero-option.sh ============================================================================ Testsuite summary for GNU coreutils 9.1.36-8ec11 ============================================================================ # TOTAL: 1 # PASS: 1 # SKIP: 0 # XFAIL: 0 # FAIL: 0 # XPASS: 0 # ERROR: 0 ============================================================================ ```
Also, allow multiple --zero flags, as this is possible with GNU ls command. Only the last one is taken into account.
79f93e3 to
61f77e9
Compare
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 #2929
(Full disclosure, I am very new to rust, and contributing mainly as a learning exercise. But I hope this change can be useful).
This flag can be used to provide a easy machine parseable output from
ls, as discussed in the GNU bug report
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=49716.
There are some peculiarities with this flag:
--zeroflag implies someother flags. Those can be overridden by setting those flags after
--zeroin the command line.--dired. This patch is not 100%compliant with GNU ls: GNU ls
--zerowill fail if--diredand-lare set, while with this patch only--diredis needed for thecommand to fail.
We also add
--diredflag to the parser, with no additional behaviourchange.
Testing done: