Re: [PATCH] builtin-grep: workaround for non GNU grep.
- From
Linus Torvalds <torvalds@osdl.org>
- Date
- May 17, 2006, 14:24 UTC
- Message-ID
- <Pine.LNX.4.64.0605170722590.10823@g5.osdl.org>
- In-Reply-To
- <7vves5geng.fsf_-_@assigned-by-dhcp.cox.net>
No, please don't do it this way.
On Wed, 17 May 2006, Junio C Hamano wrote:
Show 17 quoted lines
>
> + * Some grep implementations do not understand -H nor --
> + * but /dev/null can be used as a substitution in most
> + * cases.
> + *
> + * However -L and -c would slightly misbehave (-L would
> + * list /dev/null as a hit, and -c would report 0 hits
> + * from /dev/null); so do not use the external one on
> + * such platforms.
> */
> - if (!cached) {
> + if (!cached &&
> + (!NO_H_OPTION_IN_GREP ||
> + (!opt->count && !opt->unmatch_name_only))) {
> hit = external_grep(opt, paths, cached);
> if (hit >= 0)
> return hit;That's the ugliest test ever, and at all the wrong levels.
Just make "external_grep()" test for the cases that it cannot handle, and return -1. That's how it's designed to work.
Linus