Index: gnu/usr.bin/grep/grep.c =================================================================== --- gnu/usr.bin/grep/grep.c +++ gnu/usr.bin/grep/grep.c @@ -79,7 +79,7 @@ static int filename_mask; /* If nonzero, use grep_color marker. */ -static int color_option; +static int color_option = 2; /* If nonzero, show only the part of a line matching the expression. */ static int only_matching; @@ -1676,13 +1676,6 @@ show_help = 1; } else color_option = 2; - if(color_option == 2) { - if(isatty(STDOUT_FILENO) && getenv("TERM") && - strcmp(getenv("TERM"), "dumb")) - color_option = 1; - else - color_option = 0; - } break; case EXCLUDE_OPTION: @@ -1725,6 +1718,13 @@ } + if(color_option == 2) { + if(isatty(STDOUT_FILENO) && getenv("TERM") && + strcmp(getenv("TERM"), "dumb")) + color_option = 1; + else + color_option = 0; + } /* POSIX.2 says that -q overrides -l, which in turn overrides the other output options. */ if (exit_on_match)