On Thu, Aug 28, 2014 at 6:22 AM, Ashwini Sharma <ak.ashwini1...@gmail.com> wrote: > Hi List, > > While verifying the command grep and analysing/comparing the behavior > with GNU and busybox. I notices following
My local copy still has the -ABC addition pending, by the way. (As in my local copy of the code does not currently compile and is full of debug print statements from where I left off trying to make that work. :) > 1. __-H__ and __-h__ options, we prefer -H over -h, GNU and Busybox prefer > the last one mentioned on command line. Easy enough to fix ("[-Hh]" at the end of the optstring). > 2. links are not followed for doing grep, i.e. grep "search" <linkToFile or > Dir> -r > no results are shown. Shouldn't the link be followed. Same issue as cp's -HLP (commit 1388). Easy enough to fix, the trick is determining what the right behavior should be. (Alas, posix's grep standard is so utterly out of touch it doesn't even mention -r let alone symlink behavior when recursing.) I'm guessing the equivalent of cp -H would be correct? (Follow command line symlinks, but not ones found while recursing.) > 3. searching in binary files, toybox gives very minimal or no results, e.g. > grep "toy" toybox_unstripped, reports 4-5 lines whereas GNU/BBox fills > the scroll buffer. This is probably the embedded NUL byte issue. (Standard C string manipulation says a string ends at the first NUL byte, but here we're getting reading "to the next newline or end of file", and that gives us strings with embedded NUL bytes, and then we ignore everything after the first NUL.) Fixing this was actually on my todo list for implementing sed, then I need to go back and add the corrected infrastructure to grep. (I also need to fix musl's regex engine to allow "\|" to work in non-extended regular expressions. We use that in grep to glue together multiple search strings, but when building against musl doing that doesn't currently work. I tracked it about halfway down last month... a couple days before my house got flooded. Kinda dropped the ball in all the distraction, that's also when my most recent stab at the grep -ABC stuff got stalled...) > The spec http://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html > doesn't mention anything for these behavior or options. Sigh. Tell me about it. :( (I'm on the Austin Group's mailing list, that's the people who update the posix spec. I keep feeling I should bother them about these things, but it's down on the todo list below getting the test suite fluffed the rest of the way out. Speaking of which, I'm still debugging Divya's contributions...) > Do have a look and give your inputs on > What is the right one to be followed? The first two are easy and I should be able to fix them tonight. The third requires new infrastructure to be written, probably not in scope for the upcoming release but I can put it on the todo list for the next one. > Thanks, > Ashwini Thanks for the bug report, Rob _______________________________________________ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net