threads / patch / 30189

patchAvoid problem with xpg4 grep in Solaris that broke t9400

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

## tl;dr

5 messages between Apr 9, 2012 and Apr 19, 2012. Diffs are folded; open one to read it.

replies: 4people: 3as markdown or json

Ben Walton· Apr 9, 2012, 20:13 UTC · lore

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(-)
Show changes to t/t9400-git-cvsserver-server.sh +2 −2
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· Apr 14, 2012, 23:19 UTC · re: Ben Walton · lore

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

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

Thanks -Ben

Show 37 quoted lines
> 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· Apr 19, 2012, 16:55 UTC · re: Ben Walton · lore

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

Ben Walton <bwalton@artsci.utoronto.ca> writes:
Show 7 quoted lines
> 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?
Show 16 quoted lines
>> 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(-)
Show changes to t/t9400-git-cvsserver-server.sh +2 −2
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· Apr 19, 2012, 17:39 UTC · re: Junio C Hamano · lore

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

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?
Show 5 quoted lines
> -    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· Apr 19, 2012, 20:06 UTC · re: Ben Walton · lore

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

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(-)
Show changes to t/t9400-git-cvsserver-server.sh +2 −2
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

← back to recent threads