[Toybox] [patch] add grep
felix.janda at posteo.de
felix.janda at posteo.de
Wed Jul 17 07:20:10 PDT 2013
Just three superficial remarks:
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?
> +void grep_main (void) {
> + buildRE ();
> +
> + if (toys.optflags & FLAG_c) TT.mode = 'c';
> + if (toys.optflags & FLAG_l) TT.mode = 'l';
> + if (toys.optflags & FLAG_q) TT.mode = 'q';
> +
> + if (toys.optc > 0) loopfiles (toys.optargs, do_grep);
> + else do_grep (0, "-");
loopfiles() already deals with "-".
Felix
1374070810.0
More information about the Toybox
mailing list