Re: issues with bsdgrep and lang/go

From: Test Rat <ttsestt_at_gmail.com>
Date: Tue, 09 Aug 2011 15:27:30 +0400
Alexander Best <arundel_at_freebsd.org> writes:

> On Tue Aug  9 11, Test Rat wrote:
>> Alexander Best <arundel_at_freebsd.org> writes:
>> 
>> [...]
>> > gmake -C 6g install
>> > gmake[1]: Entering directory `/usr/ports/lang/go/work/go-20110515/src/cmd/6g'
>> > quietgcc -I"/usr/ports/lang/go/work/go-20110515/include" -ggdb -O2 -c "/usr/ports/lang/go/work/go-20110515/src/cmd/6g/list.c"
>> > egrep: : error: .Each undeclared identifier|: error: for each function
>> > it appears|is dangerous, better use|is almost always misused|: In
>> > function |: At top level: |In file included from| from: No such file
>> > or directory
>> 
>> Do you use GREP_OPTIONS?
>
> otaku% type $GREP_OPTIONS
> otaku% echo foo | env -i GREP_OPTIONS= bsdgrep foo
> env: bsdgrep: No such file or directory
> otaku%

Actually, it's lang/go that seems to set the environment variable.

  $ fgrep -r GREP_OPTIONS $(make -V WRKSRC)
  .../src/cmd/gc/mkopnames:export GREP_OPTIONS=""
  .../src/Make.inc:GREP_OPTIONS:=
  .../src/Make.inc:export LANG LC_ALL LC_CTYPE GREP_OPTIONS GREP_COLORS
  .../src/Make.inc: _at_echo export GREP_OPTIONS="$(GREP_OPTIONS)"
  .../test/run:unset GREP_OPTIONS   # in case user has a non-standard set
  .../doc/devel/weekly.html:* build: clear custom variables like GREP_OPTIONS,

Try below workaround. It also makes empty GREP_COLOR behave like gnugrep(1).

%%
Index: usr.bin/grep/grep.c
===================================================================
--- usr.bin/grep/grep.c	(revision 224705)
+++ usr.bin/grep/grep.c	(working copy)
_at__at_ -304,7 +304,7 _at__at_ init_color(const char *d)
 	char *c;
 
 	c = getenv("GREP_COLOR");
-	return (c != NULL ? c : d);
+	return (c != NULL && c[0] != '\0' ? c : d);
 }
 
 int
_at__at_ -360,7 +360,7 _at__at_ main(int argc, char *argv[])
 
 	/* support for extra arguments in GREP_OPTIONS */
 	eargc = 0;
-	if (eopts != NULL) {
+	if (eopts != NULL && eopts[0] != '\0') {
 		char *str;
 
 		/* make an estimation of how many extra arguments we have */
_at__at_ -373,6 +373,7 _at__at_ main(int argc, char *argv[])
 		eargc = 0;
 		/* parse extra arguments */
 		while ((str = strsep(&eopts, " ")) != NULL)
+			if(*str != '\0')
 			eargv[eargc++] = grep_strdup(str);
 
 		aargv = (char **)grep_calloc(eargc + argc + 1,
%%
Received on Tue Aug 09 2011 - 09:27:41 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:16 UTC