[Toybox] [PATCH] Make ls.test work without awk.

Rob Landley rob at landley.net
Tue Apr 11 12:14:56 PDT 2017


On 04/05/2017 12:28 PM, enh wrote:
>  tests/ls.test | 4 ++++
>  1 file changed, 4 insertions(+)

This patch removes no lines, it just adds a new test. How does this make
it work without awk in a way that wasn't previously the case? (The
description doesn't match what the patch does?)

Also, minor quibble, they're called symlinks (symbolic links) not
softlinks. Kinda fixed in stone on linux because that's what the syscall
to make 'em is called (man 2 symlink).

Also, I want a grep option that ignores whitespace differences like
patch -l does. Squash all runs of whitespace to one ascii 32 space
character, then compare. Alas I'd probably have to use a --longopt for
the name and I dislike those slightly more than I want this feature.

And if you want to be really cruel to this test:

ln -s "three -> four" "one -> two"
lrwxrwxrwx 1 landley landley 13 Apr 11 12:39 one -> two -> three -> four

Which is why ls -1b and readlink exist, but my -b needs upgrading? It's
wildcarding stuff out ala -q but that can cause collisions, and given
the other one escapes spaces what it really means by "nongraphic" is
escape anything that prevents the shell from seeing this as a single
argument, and I'm not entirely sure what that list is...

$ mkdir sub
$ cd sub
$ touch "$(echo -e "$(X=0;while [ $X -lt 255 ];do X=$(($X+1));[ $X -eq
47 ]&& continue;printf '\\x%02x' $X; done)")"
$ ls -b

Answer: it's anything <= 32 and >= 128, which gets an octal escape,
except for \a\b\t\n\v\f\r and "\ ". And backslash is escaped with
another backslash.

And the FUN part is that I should add the above to the test suite. Wow
that's ugly. Should use the octal not hex escapes though...

(You want to know why I can't work through my todo list until it's
smaller? That's why. Working through my todo list makes it BIGGER.
Always has.)

Except... looking in ls there's code to do this. Why isn't it
triggering... Huh, Izabera pointed out that ubuntu's ls defaults to -q
and so I made it do that, and -q trumps -b. Blah.

Ok, fixed and my code is escaping \e which ubuntu's ls isn't. But both
printf and echo support \e so I think I'm right. :)

Rob


More information about the Toybox mailing list