# [PATCH] Avoid problem with xpg4 grep in Solaris that broke t9400

5 messages from 2012-04-09 to 2012-04-19. Participants: Ben Walton, Junio C Hamano.
Thread: https://gitlist.dev/t/30189

## Ben Walton, 2012-04-09 20:13

Subject: [PATCH] Avoid problem with xpg4 grep in Solaris that broke t9400
Message-ID: <1334002409-5708-1-git-send-email-bwalton@artsci.utoronto.ca>
URL: https://gitlist.dev/e/1334002409-5708-1-git-send-email-bwalton%40artsci.utoronto.ca

```
The grep in Solaris' /usr/xpg4/bin as found by the default
SANE_TOOL_PATH was not properly handling the 'cvs co -c (shows module
database)' test.  The [\t ] character set selection does not properly
trigger so the first grep in the test fails.

Instead of working around this issue, switch to using the standard
test_cmp() shell function to perform the comparison instead.

Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca>
---

It's possible that the specific pair of grep statements is required.
It's looking for tab or space, so maybe we get either character in
some cases, depending on cvs version?  This passed the test suite
using cvs 1.12.13 for OpenCSW.

If there is a reason for the original construction, I'll find a more
creative work around for this problem.

 t/t9400-git-cvsserver-server.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
index 9199550..df1405f 100755
--- a/t/t9400-git-cvsserver-server.sh
+++ b/t/t9400-git-cvsserver-server.sh
@@ -500,8 +500,8 @@ test_expect_success 'cvs status (no subdirs in header)' '
 cd "$WORKDIR"
 test_expect_success 'cvs co -c (shows module database)' '
     GIT_CONFIG="$git_config" cvs co -c > out &&
-    grep "^master[	 ]\+master$" < out &&
-    ! grep -v "^master[	 ]\+master$" < out
+    echo "master	master" > out.expected &&
+    test_cmp out out.expected
 '
 
 #------------
-- 
1.7.9

```

## Ben Walton, 2012-04-14 23:19

Subject: Re: [PATCH] Avoid problem with xpg4 grep in Solaris that broke t9400
Message-ID: <1334445524-sup-1455@pinkfloyd.chass.utoronto.ca>
URL: https://gitlist.dev/e/1334445524-sup-1455%40pinkfloyd.chass.utoronto.ca
In-Reply-To: <1334002409-5708-1-git-send-email-bwalton@artsci.utoronto.ca>

```
Excerpts from Ben Walton's message of Mon Apr 09 16:13:29 -0400 2012:

Bump?

Thanks
-Ben

> The grep in Solaris' /usr/xpg4/bin as found by the default
> SANE_TOOL_PATH was not properly handling the 'cvs co -c (shows module
> database)' test.  The [\t ] character set selection does not properly
> trigger so the first grep in the test fails.
> 
> Instead of working around this issue, switch to using the standard
> test_cmp() shell function to perform the comparison instead.
> 
> Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca>
> ---
> 
> It's possible that the specific pair of grep statements is required.
> It's looking for tab or space, so maybe we get either character in
> some cases, depending on cvs version?  This passed the test suite
> using cvs 1.12.13 for OpenCSW.
> 
> If there is a reason for the original construction, I'll find a more
> creative work around for this problem.
> 
>  t/t9400-git-cvsserver-server.sh |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
> index 9199550..df1405f 100755
> --- a/t/t9400-git-cvsserver-server.sh
> +++ b/t/t9400-git-cvsserver-server.sh
> @@ -500,8 +500,8 @@ test_expect_success 'cvs status (no subdirs in header)' '
>  cd "$WORKDIR"
>  test_expect_success 'cvs co -c (shows module database)' '
>      GIT_CONFIG="$git_config" cvs co -c > out &&
> -    grep "^master[     ]\+master$" < out &&
> -    ! grep -v "^master[     ]\+master$" < out
> +    echo "master    master" > out.expected &&
> +    test_cmp out out.expected
>  '
>  
>  #------------
--
Ben Walton
Systems Programmer - CHASS
University of Toronto
C:416.407.5610 | W:416.978.4302

```

## Junio C Hamano, 2012-04-19 16:55

Subject: Re: [PATCH] Avoid problem with xpg4 grep in Solaris that broke t9400
Message-ID: <xmqqfwbzslt2.fsf@junio.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqfwbzslt2.fsf%40junio.mtv.corp.google.com
In-Reply-To: <1334445524-sup-1455@pinkfloyd.chass.utoronto.ca>

```
Ben Walton <bwalton@artsci.utoronto.ca> writes:

> Excerpts from Ben Walton's message of Mon Apr 09 16:13:29 -0400 2012:
>
> Bump?
> ...
>> It's possible that the specific pair of grep statements is required.
>> It's looking for tab or space, so maybe we get either character in
>> some cases, depending on cvs version?

Bump, anybody, on this point?

>> If there is a reason for the original construction, I'll find a more
>> creative work around for this problem.
>> 
>>  t/t9400-git-cvsserver-server.sh |    4 ++--
>>  1 files changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
>> index 9199550..df1405f 100755
>> --- a/t/t9400-git-cvsserver-server.sh
>> +++ b/t/t9400-git-cvsserver-server.sh
>> @@ -500,8 +500,8 @@ test_expect_success 'cvs status (no subdirs in header)' '
>>  cd "$WORKDIR"
>>  test_expect_success 'cvs co -c (shows module database)' '
>>      GIT_CONFIG="$git_config" cvs co -c > out &&
>> -    grep "^master[     ]\+master$" < out &&
>> -    ! grep -v "^master[     ]\+master$" < out

Is it really the character class, or is it the GNUism "\+", that breaks
this?

In other words, does it work if you patch it like this instead?

 t/t9400-git-cvsserver-server.sh |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
index 9199550..173bf3d 100755
--- a/t/t9400-git-cvsserver-server.sh
+++ b/t/t9400-git-cvsserver-server.sh
@@ -500,8 +500,8 @@ test_expect_success 'cvs status (no subdirs in header)' '
 cd "$WORKDIR"
 test_expect_success 'cvs co -c (shows module database)' '
     GIT_CONFIG="$git_config" cvs co -c > out &&
-    grep "^master[	 ]\+master$" < out &&
-    ! grep -v "^master[	 ]\+master$" < out
+    grep "^master[	 ][ 	]*master$" <out &&
+    ! grep -v "^master[	 ][ 	]*master$" <out
 '
 
 #------------

```

## Ben Walton, 2012-04-19 17:39

Subject: Re: [PATCH] Avoid problem with xpg4 grep in Solaris that broke t9400
Message-ID: <1334857109-sup-7979@pinkfloyd.chass.utoronto.ca>
URL: https://gitlist.dev/e/1334857109-sup-7979%40pinkfloyd.chass.utoronto.ca
In-Reply-To: <xmqqfwbzslt2.fsf@junio.mtv.corp.google.com>

```
Excerpts from Junio C Hamano's message of Thu Apr 19 12:55:53 -0400 2012:

> Is it really the character class, or is it the GNUism "\+", that breaks
> this?

Yes, you're right, it is the \+.  I didn't look carefully enough when
I saw that test_cmp looked like the way to fix this.

I'll re-word the patch...

> In other words, does it work if you patch it like this instead?

> -    grep "^master[     ]\+master$" < out &&
> -    ! grep -v "^master[     ]\+master$" < out
> +    grep "^master[     ][     ]*master$" <out &&
> +    ! grep -v "^master[     ][     ]*master$" <out
>  '

This does work and if there is some significance to the space or tab
then it's a better patch.

Thanks
-Ben
--
Ben Walton
Systems Programmer - CHASS
University of Toronto
C:416.407.5610 | W:416.978.4302

```

## Junio C Hamano, 2012-04-19 20:06

Subject: Re: [PATCH] Avoid problem with xpg4 grep in Solaris that broke t9400
Message-ID: <xmqqlilrv63m.fsf@junio.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqlilrv63m.fsf%40junio.mtv.corp.google.com
In-Reply-To: <1334857109-sup-7979@pinkfloyd.chass.utoronto.ca>

```
Ben Walton <bwalton@artsci.utoronto.ca> writes:

> This does work and if there is some significance to the space or tab
> then it's a better patch.

Ok, I'll queue this:

-- >8 --
From: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] t9400: fix gnuism in grep

Using "\+" in "grep" and expecting that it means one or more
is a GNUism.  Spell it in a dumb and portable way.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t9400-git-cvsserver-server.sh |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
index 9199550..173bf3d 100755
--- a/t/t9400-git-cvsserver-server.sh
+++ b/t/t9400-git-cvsserver-server.sh
@@ -500,8 +500,8 @@ test_expect_success 'cvs status (no subdirs in header)' '
 cd "$WORKDIR"
 test_expect_success 'cvs co -c (shows module database)' '
     GIT_CONFIG="$git_config" cvs co -c > out &&
-    grep "^master[	 ]\+master$" < out &&
-    ! grep -v "^master[	 ]\+master$" < out
+    grep "^master[	 ][ 	]*master$" <out &&
+    ! grep -v "^master[	 ][ 	]*master$" <out
 '
 
 #------------
-- 
1.7.10.282.g21208e

```
