Re: [PATCH] grep: fix exit status if external_grep() returns error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Clemens Buchacher <drizzd@xxxxxx> writes:

> diff --git a/builtin-grep.c b/builtin-grep.c
> index ad0e0a5..b577738 100644
> --- a/builtin-grep.c
> +++ b/builtin-grep.c
> @@ -500,9 +500,9 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached,
>  	 * be a lot more optimized
>  	 */
>  	if (!cached && external_grep_allowed) {
> -		hit = external_grep(opt, paths, cached);
> -		if (hit >= 0)
> -			return hit;
> +		int ret = external_grep(opt, paths, cached);
> +		if (ret >= 0)
> +			return ret;

Well caught, and this deserves to go to maint.

An alternative would be to reset hit to zero if we decide to use the
internal one after this conditional.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]