Greetings!

I've implemented a `-p` flag for grep, which disables a behaviour that
the exit status is used (abused?) to signal whether any match
occurred. In many cases, you won't notice this. Also, in many cases,
shell scripts don't check for errors.

Now, for an example where it makes a difference. Consider a Bash script
like this:

  # enable automatic error handling
  set -eo pipefail
  # check for string "issues" in a logfile
  cat logfile | grep issue | sort --unique

If there are no issues in the logs, grep return exit code 1 and the
shell interprets this as an error and exits itself.

I've implemented that feature here, though it lacks tests yet:
https://github.com/UlrichEckhardt/busybox/tree/grep-pipe-option
Also, I'm currently trying to get the same feature into GNU grep as
well, the long form `--pipe` is used there. I've also considered
`--filter` (because it only filters) as alternative. I'm not fully
happy with either one, maybe someone here comes up with a better
suggestion.

If you want, grab the first commit in there, it just fixes a small typo.

I'd be happy to hear any suggestions!


Cheers!


Uli
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to