[Toybox] [PATCH] ls -N.

Rob Landley rob at landley.net
Thu Dec 1 12:32:44 PST 2022


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)

When is program NOT 'ls' in the man page for ls? 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
   ̗̤̯̥͓B͙̘̰͉̠͘E̫͇̜͉̯    ̡͔O͟N͎E̤͖̹̥̱͔̟             'one two four'    ̹̭͟ͅO̧̮̝̗̰ͅN͏̖͖̹L̫̮͎͙̯̩͕Y̘͓
   ̬̙̗̭̩C̷͉̻A̛̜̜͉n̝͚̯̗̤̻̺  'one'$'\t''two'  'one two three'   T̹̳H̳e̪̭̝͙͕R̳̪͕̬̼̝͙Ȩ̮̖̤
  $ ls -b
  B͙̘̰͉̠͘E̫͇̜͉̯  ̬̙̗̭̩C̷͉̻A̛̜̜͉n̝͚̯̗̤̻̺  ̡͔O͟N͎E̤͖̹̥̱͔̟  one\ttwo  one\ two\ four  one\ two\ three  ̹̭͟ͅO̧̮̝̗̰ͅN͏̖͖̹L̫̮͎͙̯̩͕Y̘͓  T̹̳H̳e̪̭̝͙͕R̳̪͕̬̼̝͙Ȩ̮̖̤

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.)

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.

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.


More information about the Toybox mailing list