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
_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to