Deleted Added
full compact
31c31
< __FBSDID("$FreeBSD: head/usr.bin/grep/grep.c 210430 2010-07-23 19:36:11Z delphij $");
---
> __FBSDID("$FreeBSD: head/usr.bin/grep/grep.c 210461 2010-07-25 08:42:18Z gabor $");
117c117
< char *color; /* --color */
---
> const char *color; /* --color */
121,123c121,123
< int devbehave = DEV_GREP; /* -D: handling of devices */
< int dirbehave = DIR_GREP; /* -dRr: handling of directories */
< int linkbehave = LINK_GREP; /* -OpS: handling of symlinks */
---
> int devbehave = DEV_READ; /* -D: handling of devices */
> int dirbehave = DIR_READ; /* -dRr: handling of directories */
> int linkbehave = LINK_READ; /* -OpS: handling of symlinks */
138a139,140
> static inline const char *init_color(const char *);
>
281a284,292
> static inline const char *
> init_color(const char *d)
> {
> char *c;
>
> c = getenv("GREP_COLOR");
> return (c != NULL ? c : d);
> }
>
418c429
< if (strcmp(optarg, "skip") == 0)
---
> if (strcasecmp(optarg, "skip") == 0)
419a431,436
> else if (strcasecmp(optarg, "read") == 0)
> devbehave = DEV_READ;
> else {
> errno = EINVAL;
> err(2, NULL);
> }
422c439
< if (strcmp("recurse", optarg) == 0) {
---
> if (strcasecmp("recurse", optarg) == 0) {
425c442
< } else if (strcmp("skip", optarg) == 0)
---
> } else if (strcasecmp("skip", optarg) == 0)
427c444,446
< else if (strcmp("read", optarg) != 0) {
---
> else if (strcasecmp("read", optarg) == 0)
> dirbehave = DIR_READ;
> else {
469c488
< Lflag = qflag = true;
---
> Lflag = true;
473c492
< lflag = qflag = true;
---
> lflag = true;
503c522
< linkbehave = LINK_GREP;
---
> linkbehave = LINK_READ;
536c555
< if (strcmp("binary", optarg) == 0)
---
> if (strcasecmp("binary", optarg) == 0)
538c557
< else if (strcmp("without-match", optarg) == 0)
---
> else if (strcasecmp("without-match", optarg) == 0)
540c559
< else if (strcmp("text", optarg) == 0)
---
> else if (strcasecmp("text", optarg) == 0)
546,555c565,581
< if (optarg == NULL || strcmp("auto", optarg) == 0 ||
< strcmp("always", optarg) == 0 ) {
< color = getenv("GREP_COLOR");
< if (color == NULL) {
< color = grep_malloc(sizeof(char) * 6);
< strcpy(color, "01;31");
< }
< } else if (strcmp("never", optarg) == 0)
< color = NULL;
< else
---
> color = NULL;
> if (optarg == NULL || strcasecmp("auto", optarg) == 0 ||
> strcasecmp("tty", optarg) == 0 ||
> strcasecmp("if-tty", optarg) == 0) {
> char *term;
>
> term = getenv("TERM");
> if (isatty(STDOUT_FILENO) && term != NULL &&
> strcasecmp(term, "dumb") != 0)
> color = init_color("01;31");
> } else if (strcasecmp("always", optarg) == 0 ||
> strcasecmp("yes", optarg) == 0 ||
> strcasecmp("force", optarg) == 0) {
> color = init_color("01;31");
> } else if (strcasecmp("never", optarg) != 0 &&
> strcasecmp("none", optarg) != 0 &&
> strcasecmp("no", optarg) != 0)