-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ls: add support for --zero
option
#2929
Labels
Comments
For reference, the description from the GNU docs:
Source: https://www.gnu.org/software/coreutils/manual/html_node/General-output-formatting.html |
pimzero
added a commit
to pimzero/coreutils
that referenced
this issue
Jul 26, 2022
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 ============================================================================ ```
pimzero
added a commit
to pimzero/coreutils
that referenced
this issue
Jul 26, 2022
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 ============================================================================ ```
pimzero
added a commit
to pimzero/coreutils
that referenced
this issue
Jul 30, 2022
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 ============================================================================ ```
sylvestre
added a commit
that referenced
this issue
Jul 31, 2022
* ls: Implement --zero flag. (#2929) 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 ============================================================================ ``` * Use the US way to spell Behavior * Fix formatting with cargo fmt -- tests/by-util/test_ls.rs * Simplify --zero flag overriding logic by using index_of Also, allow multiple --zero flags, as this is possible with GNU ls command. Only the last one is taken into account. Co-authored-by: Sylvestre Ledru <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
GNU's
ls
now supports a--zero
option, where line endings are null bytes instead of newlines. This feature is tested in thetests/ls/zero-option
GNU test.The text was updated successfully, but these errors were encountered: