X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-grep.c;h=a5b6719a1af014497399ea6ff4f1a6f3852a0570;hb=bf3c523c3fd641609adcef67dcec47a43a6abd60;hp=01be9bf7ff74731969384cc91dad2e20d08d81bc;hpb=905bf7742cf5f4a6dea2e75ba2dbd89d5dfaa793;p=git.git diff --git a/builtin-grep.c b/builtin-grep.c index 01be9bf7f..a5b6719a1 100644 --- a/builtin-grep.c +++ b/builtin-grep.c @@ -367,7 +367,7 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached) push_arg("-h"); if (opt->regflags & REG_EXTENDED) push_arg("-E"); - if (opt->regflags & REG_ICASE) + if (opt->ignore_case) push_arg("-i"); if (opt->binary == GREP_BINARY_NOMATCH) push_arg("-I"); @@ -433,7 +433,11 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached) if (opt->color_external && strlen(opt->color_external) > 0) push_arg(opt->color_external); + } else { + unsetenv("GREP_COLOR"); + unsetenv("GREP_COLORS"); } + unsetenv("GREP_OPTIONS"); hit = 0; argc = nr; @@ -706,8 +710,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix) OPT_GROUP(""), OPT_BOOLEAN('v', "invert-match", &opt.invert, "show non-matching lines"), - OPT_BIT('i', "ignore-case", &opt.regflags, - "case insensitive matching", REG_ICASE), + OPT_BOOLEAN('i', "ignore-case", &opt.ignore_case, + "case insensitive matching"), OPT_BOOLEAN('w', "word-regexp", &opt.word_regexp, "match patterns only at word boundaries"), OPT_SET_INT('a', "text", &opt.binary, @@ -837,6 +841,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix) external_grep_allowed = 0; if (!opt.pattern_list) die("no pattern given."); + if (!opt.fixed && opt.ignore_case) + opt.regflags |= REG_ICASE; if ((opt.regflags != REG_NEWLINE) && opt.fixed) die("cannot mix --fixed-strings and regexp"); compile_grep_patterns(&opt);