Re: [PATCH/RFC] SunOS grep does not understand -C<n>

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Brandon Casey
Date: Friday, July 24, 2009 - 8:43 am

Junio C Hamano wrote:

Hmm.  I have _not_ been setting NO_EXTERNAL_GREP and the tests have _not_
been failing.

The system grep does not seem to have the -C option:

   # /usr/xpg4/bin/grep -C1 include ws.c
   /usr/xpg4/bin/grep: illegal option -- C
   Usage:  grep [-E|-F] [-c|-l|-q] [-bhinsvwx] [file ...]
   grep [-E|-F] [-c|-l|-q] [-bhinsvwx] -e pattern... [-f pattern_file]...[file...]
   grep [-E|-F] [-c|-l|-q] [-bhinsvwx] [-e pattern]... -f pattern_file [file...]

but git grep -C1 works fine

   # git grep -C1 include ws.c
   ws.c-
   ws.c:#include "cache.h"
   ws.c:#include "attr.h"
   ws.c-

I have been compiling with the SUNWspro compiler suite though, and I see these
statements in builtin-grep.c:

   #ifndef NO_EXTERNAL_GREP
   #ifdef __unix__
   #define NO_EXTERNAL_GREP 0
   #else
   #define NO_EXTERNAL_GREP 1
   #endif
   #endif

So possibly, the SUNWspro compiler does not set the __unix__ macro.  A quick
compile of a test program confirms it.

   #include <stdio.h>

   int main (int argc, char* argv[])
   {
   #ifdef __unix__
   	puts("__unix__ is set");
   #else
   	puts("__unix__ is not set");
   #endif
   	return 0;
   }

   # /opt/SUNWspro/bin/cc -o test.out test.c
   ./test.out
   __unix__ is not set

   # gcc -o test.out test.c
   __unix__ is set

So, I have been getting NO_EXTERNAL_GREP all along without knowing it.

-brandon
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH/RFC] SunOS grep does not understand -C&lt;n&gt;, Junio C Hamano, (Thu Jul 23, 10:30 pm)
Re: [PATCH/RFC] SunOS grep does not understand -C&lt;n&gt;, Junio C Hamano, (Thu Jul 23, 11:27 pm)
Re: [PATCH/RFC] SunOS grep does not understand -C<n>, Brandon Casey, (Fri Jul 24, 8:43 am)
Re: [PATCH/RFC] SunOS grep does not understand -C&lt;n&gt;, Junio C Hamano, (Fri Jul 24, 8:55 am)