On 28/07/2021 02:14, Paul Eggert wrote:
On 7/26/21 8:00 AM, Pádraig Brady wrote:

So I'd have a slight preference for --zero.

Also what about having --zero imply:
    --quoting-style=literal --show-control-chars --format=single-column
That seems like a fine shortcut given that would be correct in the vast
majority of cases,
and that the need for the above may not be obvious to users.

Also a small point; should --dired disable --null as it may then be non
parseable?

Thanks, all good suggestions. For --dired vs --zero I thought it better
simply to prohibit the combination since neither should be in 'ls' shell
aliases, and prohibiting means we can add it later if we like. I
installed the attached patches to do this (plus the other stuff I
mentioned in my reply to Berny).

The first patch is a cleanup because I had a bit of trouble following
the forest of 'if's inside of ls.c's decode_switches function and I
thought it better to avoid unnecessary syscalls while I was at it.

The second patch does the real work.


That all looks great.

I see --zero implies --format=single-column, but allows --format=long.
That's the right default, but also most flexible.

I'll apply the attached later to augment/document the test
with the various supported option combinations.

thanks!
Pádraig
>From 4f71c9913894a1de0a8a3303fe88f9f75bb25fbb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <p...@draigbrady.com>
Date: Wed, 28 Jul 2021 12:51:35 +0100
Subject: [PATCH] tests: augment new ls --zero test cases

* tests/ls/zero-option.sh: Check for the disabled, disallowed,
and allowed option combinations.
---
 tests/ls/zero-option.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tests/ls/zero-option.sh b/tests/ls/zero-option.sh
index a6883917f..5564f3b77 100755
--- a/tests/ls/zero-option.sh
+++ b/tests/ls/zero-option.sh
@@ -21,7 +21,15 @@ print_ver_ ls
 
 mkdir dir && touch dir/a dir/b dir/cc || framework_failure_
 
-LC_ALL=C ls --zero dir >out || fail=1
+allowed_options='-l'  # explict -l with --zero is allowed
+LC_ALL=C ls $allowed_options --zero dir >out || fail=1
+grep '^total' out || fail=1  # Ensure -l honored
+
+disallowed_options='-l --dired'  # dired only enabled with -l
+returns_ 2 ls $disallowed_options --zero dir || fail=1
+
+disabled_options='--color=always -x -m -C -Q -q'
+LC_ALL=C ls $disabled_options --zero dir >out || fail=1
 tr '\n' '\0' <<EOF >exp
 a
 b
-- 
2.26.2

Reply via email to