# [PATCH] t/annotate-tests: Use echo & cat instead of sed

3 messages from 2011-05-05 to 2011-05-05. Participants: Brian Gernhardt, Junio C Hamano, Arjen Laarhoven.
Thread: https://gitlist.dev/t/27259

## Brian Gernhardt, 2011-05-05 04:43

Subject: [PATCH] t/annotate-tests: Use echo & cat instead of sed
Message-ID: <1304570617-17603-1-git-send-email-brian@gernhardtsoftware.com>
URL: https://gitlist.dev/e/1304570617-17603-1-git-send-email-brian%40gernhardtsoftware.com

```
The use of the sed command "1i No robots allowed" caused the version
of sed in OS X to die with

   sed: 1: "1i "No robots allowed"\n": command i expects \ followed by
   text

Since this command was just trying to add a single line to the
beginning of the file, do the same with "echo > file.net && cat file
>> file.new"

Unbreaks t8001 and t8002 on OS X 10.6.7
---
 t/annotate-tests.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index abb1885..c56a77d 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -127,7 +127,8 @@ test_expect_success \
 
 test_expect_success \
     'an obfuscated email added' \
-    'sed -e "1i No robots allowed" < file > file.new &&
+    'echo "No robots allowed" > file.new &&
+     cat file >> file.new &&
      mv file.new file &&
      GIT_AUTHOR_NAME="E" GIT_AUTHOR_EMAIL="E at test dot git" git commit -a -m "norobots"'
 
-- 
1.7.5.258.g6ba2f

```

## Junio C Hamano, 2011-05-05 05:39

Subject: Re: [PATCH] t/annotate-tests: Use echo & cat instead of sed
Message-ID: <7vk4e5bt90.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vk4e5bt90.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1304570617-17603-1-git-send-email-brian@gernhardtsoftware.com>

```
An earlier patch from Arjen Laarhoven

  From: Arjen Laarhoven <arjen@yaph.org>
  Subject: [PATCH] annotate.sh: Fix failing test on OS X
  Date: Wed,  4 May 2011 15:36:21 +0200
  Message-ID: <1304516181-92364-1-git-send-email-arjen@yaph.org>

seems to attempt to address the same issue but with a twist to deal with
an incomplete line at the end of file.

Arjen, does Brian's patch look good to you, too?  It is much less tricky
and should look obviously correct even to people who sees the code in
question for the first time.

Thanks, both.

```

## Arjen Laarhoven, 2011-05-05 07:43

Subject: Re: [PATCH] t/annotate-tests: Use echo & cat instead of sed
Message-ID: <20110505074343.GA17328@regex.yaph.org>
URL: https://gitlist.dev/e/20110505074343.GA17328%40regex.yaph.org
In-Reply-To: <7vk4e5bt90.fsf@alter.siamese.dyndns.org>

```
On Wed, May 04, 2011 at 10:39:55PM -0700, Junio C Hamano wrote:
> An earlier patch from Arjen Laarhoven
> 
>   From: Arjen Laarhoven <arjen@yaph.org>
>   Subject: [PATCH] annotate.sh: Fix failing test on OS X
>   Date: Wed,  4 May 2011 15:36:21 +0200
>   Message-ID: <1304516181-92364-1-git-send-email-arjen@yaph.org>
> 
> seems to attempt to address the same issue but with a twist to deal with
> an incomplete line at the end of file.
> 
> Arjen, does Brian's patch look good to you, too?  It is much less tricky
> and should look obviously correct even to people who sees the code in
> question for the first time.

Yup, this looks much better than my fix.  At least I learned something
about the sed incompatibilities ;-)

Arjen

-- 
Arjen Laarhoven

The presence of those seeking the truth is infinitely to be preferred to 
those who think they've found it.
                                -- Terry Pratchett, "Monstrous Regiment"

```
