Re: [Toybox] [PATCH] Make ls.test work without awk.
On 04/11/2017 02:56 PM, enh wrote: > 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. > > > speaking of which: all the blkid tests fail if you run it on the desktop > because you don't output trailing spaces. Because trailing spaces are usually bad. :) And my ls -C has one space between columns as its minimal packing, when ubuntu has two. (Do a "ls toys" in the toybox source, for example. The default is -C.) That was a judgement call but if -m can do one space and consider it legible why can't -C? > i'm not sure whether to > "break" toybox blkid to just always output trailing spaces or make the > test less readable to allow either output. (regular expression matches > rather than just literal matches might help here.) Hence grep ignoring whitespace. :P Invoking my "black belt in horrible solutions", I could make a sgrep shell function that modifies grep's first argument to replace each " " with "[:space:][:space:]*" and then add a "[:space:]*" to the beginning and the end... This fixes it for the test code but not as a generally available thing. (I still have to redo adding grep color support. It turns out to be intrusive because it's a second user of the -o logic which is currently specific to -o...) Not sure which approach to take... > (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.) > > everyone else's too. this is why we give in and have bug databases. > anr/or XFAIL tests. No, I've met people who go through a todo list and reach the end without new todo items. Not sure if this is "boring projects", "boring people", or some sort of skill I haven't got. > 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. :) I changed the default output (when there's a tty) to -b rather than -q, so it's accurately escaping stuff instead of wildcarding it out. This differs from upstream ls but I think is better behavior. I can change it back if it breaks stuff for you. Rob ___ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net
Re: [Toybox] [PATCH] Make ls.test work without awk.
On Tue, Apr 11, 2017 at 12:14 PM, Rob Landleywrote: > 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?) > yeah, i fucked up trying to manage too many patches at once. those four lines should replace the four lines immediately below. > 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). > (yeah, that was me only changing the part that _needed_ to change. except i screwed that up so it was no longer obvious.) > 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. > speaking of which: all the blkid tests fail if you run it on the desktop because you don't output trailing spaces. i'm not sure whether to "break" toybox blkid to just always output trailing spaces or make the test less readable to allow either output. (regular expression matches rather than just literal matches might help here.) > 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.) > everyone else's too. this is why we give in and have bug databases. anr/or XFAIL tests. > 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 > -- Elliott Hughes - http://who/enh - http://jessies.org/~enh/ Android native code/tools questions? Mail me/drop by/add me as a reviewer. ___ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net
Re: [Toybox] [PATCH] Make ls.test work without awk.
On 04/11/2017 02:14 PM, Rob Landley wrote: > 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. :) But that's wrong because it escapes the high ascii stuff by default, and that produces unicode characters. So if they didn't _explicitly_ say -b then I don't want to escape unicode. Grrr. Rob ___ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net
Re: [Toybox] [PATCH] Make ls.test work without awk.
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 ___ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net
[Toybox] [PATCH] Make ls.test work without awk.
--- tests/ls.test | 4 1 file changed, 4 insertions(+) From 07389a6dca9572e4377d9fbd6c3d82a0610229d4 Mon Sep 17 00:00:00 2001 From: Elliott HughesDate: Wed, 5 Apr 2017 10:27:58 -0700 Subject: [PATCH] Make ls.test work without awk. --- tests/ls.test | 4 1 file changed, 4 insertions(+) diff --git a/tests/ls.test b/tests/ls.test index b29c478..86116cb 100755 --- a/tests/ls.test +++ b/tests/ls.test @@ -33,6 +33,10 @@ testing "with -F" "$IN && ls -F; $OUT" "dir1/\ndir2/\nfile1.txt\nfile2.txt\n" "" testing "with -dk *" "$IN && ls -dk *; $OUT" "dir1\ndir2\nfile1.txt\nfile2.txt\n" "" "" ln -s file1.txt lstest/slink +testing "softlink - long listing" \ +"$IN && ls -l slink | grep -q -- ' slink -> file1.txt' && echo ok ; $OUT" \ +"ok\n" "" "" + testing "softlink - long listing" "$IN && ls -l slink | awk '{ print \$NF }' ; $OUT" \ "file1.txt\n" "" "" rm -f lstest/slink -- 2.12.2.715.g7642488e1d-goog ___ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net