[Toybox] [PATCH] ls -N.

enh enh at google.com
Thu Dec 1 12:32:43 PST 2022


On Thu, Dec 1, 2022 at 12:21 PM Rob Landley <rob at landley.net> wrote:

> On 12/1/22 14:17, Rob Landley wrote:
> > Anyway, applied, I should squint at it more after lunch...
>
> Except:
>
>   $ ls -Nb | wc
>       274     274    4075
>   $ ./toybox ls -Nb
>   ls: No 'b' with 'N' (see "ls --help")
>
> It's not [!Nb] it's [-Nb] which means the test setting FLAG_b if we have a
> tty
> should test if (!FLAG(N)) and _what_ is show-control-chars doing:
>
>        --show-control-chars
>               show nongraphic characters as-is (the default, unless
> program is
>               'ls' and output is a terminal)
>

(warning: sensitive viewers may want to look away now.)


> When is program NOT 'ls' in the man page for ls?


when it's dir(1) for the ex-DOS crowd 🤢


> Meanwhile, upstream debian grew
> a new mode and instead of -b is defaulting to that new one, so my torture
> test
> dir looks like:
>
>   $ ls
>    BE    ̡͔O͟N͎E             'one two four'    ̹̭͟ͅON͏̖͖̹LY̘͓
>    C̷͉̻A̛̜̜͉n  'one'$'\t''two'  'one two three'   T̹̳H̳eRȨ̮̖̤
>   $ ls -b
>   BE  C̷͉̻A̛̜̜͉n  ̡͔O͟N͎E  one\ttwo  one\ two\ four  one\ two\ three
> ̹̭͟ͅON͏̖͖̹LY̘͓  T̹̳H̳eRȨ̮̖̤
>
> Which I have been STUDIOUSLY IGNORING since it happened. (I actually hate
> it,
> because it means most big dirty directories that display as a single column
> because they have a long name somewhere but ALSO have something with a
> space in
> the name somewhere wind up gratuitously indented one space, and you can't
> make
> it stop without an "alias" to get the old behavior back.)
>

yeah, that annoyed me when i first saw it. i still don't really understand
the motivation either. unless they're just giving me another reason to have
toybox higher up my $PATH :-)

there's also the `--quoting-style=` section of the info page, where there's
a bunch of stuff that _sounds_ useful, but i assume based on past
experience is likely to be similarly annoying in practice.


> Rob
>
> P.S. the current -b test is tty and if (!FLAG(show_control_chars)) but the
> longopt for -q is --hide-control-chars so that technically undoes -q not
> -b. The
> long for -N is --literal and the long for -b is --escape and there's no
> obvious
> relationship between those and it would be REALLY NICE if the man page
> says that
> -b undoes -N and -Q undoes -q except -Q isn't --hide-control-chars it's
> --quote-name which is the new nonsense they added and made the default.
> They
> used up the -Q character for something else LONG AFTER adding
> --hide-control-chars without a corresponding short opt because gnu.
>

(as we determined years ago, "this is what happens when 'design' is done by
drive-by commits".)


> P.P.S. And I still need to fix the flag generation so there isn't an
> easily made
> mistake requiring too much inside knowledge to avoid making. After lunch.
>
> P.P.P.S. I _do_ actually have the funky quoting logic under construction
> in sh.c
> because declare -p and friends need it, but I really really really hate
> this
> feature and AESTHETICALLY don't want it to be the default because of the
> gratuitous indenting I mentioned earlier. I know they added it because
> people
> don't know how to write shell scripts. And made it the default because
> people
> don't know that they don't know how to write shell scripts. Grrr... I'm
> gonna
> have to do it, aren't I? Dowanna... Sigh.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20221201/f41fb228/attachment.htm>


More information about the Toybox mailing list