[Toybox] [patch] add grep

Strake strake888 at gmail.com
Sat Jul 20 07:52:18 PDT 2013


Felix <felix.janda at posteo.de> wrote:
> The *error_[msg,exit] functions should be used instead of [err,warn]x from err.h. > These functions use xexit() instead of exit(). In xexit() calls exit() unless
> toys.rebound nonzero (e.g. when invoked from toysh) and in this case it
> long_jmps to toys.rebound.
>
> The global variable c seems to have a similar purpose as toys.exitval. Is it necessary?

I doubt it. See below.

Isaac <idunham at lavabit.com> wrote:
>> I added some more flags: EFhinovclqe*f*m#
> what the kernel needs:     EFabhiovwqd*e*m#
> (just for reference)
> -a is "treat anything as text"

Would be no-op, so will ignore.

> -b is "print binary offset"
> -d (read|skip|recurse) is a state switch that looks like insanity.
> -w matches a whole word.
>
>> Too, I moved it to pending, and disabled it by default.
>>
>> I may hack it further later, but I already feel dirty for adding so
>> many features.
>
> Well, I compiled toybox with musl and gcc complains about using regoff_t
> as an int, so I took a look.
> I didn't dare to poke at that, but noticed the exit (c).
> This would break toysh and anything else that may xexec() grep, so I
> started
> writing a patch to use xexit/error_exit/toys.exitval.
>
> By now I've also added -Hs because they were trivial.
> Mind if I submit it?

No; please do.

> In my testing it seemed that -e and -f don't work;
> it looks like they're not hooked up?

Just noticed a double free in -f code, derp. Unbroke that. Works for
me now at least. Will send when I merge yours.

> I noticed one oddity in your style: is there any reason to use
> function (args); //normal is function(args) ?

Yes: to my eyes, it looks crowded with no space, and is easier to read
with a space.

> The latter style makes a regex search for functions simpler.

I just use the function name.

 1374331938.0


More information about the Toybox mailing list