Fix sed syntax in t7502-commit for OSX
PATCH 1/1 Fix sed syntax in t7502-commit for OSX
The OSX version of sed interprets the command as argument to the -i option.
--- t/t7502-commit.sh | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
t/t7502-commit.sh +1 -1
@@ -166,7 +166,7 @@ test_expect_success 'author different from committer' ' test_cmp expect actual ' -sed -i '$d' expect +sed -i -e '$d' expect echo "# Committer: #" >> expect unset GIT_COMMITTER_EMAIL
Signature · 1 line
1.5.5.1.215.g64c0d
Quoted 12 lines · Marcel Koeppen
The OSX version of sed interprets the command as argument to the -i option.
Signed-off-by Marcel Koeppen <[email protected]>--- t/t7502-commit.sh | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)t/t7502-commit.sh +0
-0
t/t7502-commit.sh test_expect_success 'author different from committer' ' · line 172
Quoted 8 lines
t/t7502-commit.sh +1
-1@@ -166,7 +166,7 @@ test_expect_success 'author different from committer' ' test_cmp expect actual ' -sed -i '$d' expect +sed -i -e '$d' expect echo "# Committer: #" >> expect unset GIT_COMMITTER_EMAIL
Two comments and a half.
This patch does not make things worse, so I do not have much against it.
However, "sed -i $cmd" is also used in templates/hooks--prepare-commit-msg and you would want to fix it as well.
But more importantly, as we are serious about portability, we should not be using "sed -i" which is not even in POSIX to begin with. Can we rewrite these places without using the in-place extension?
PATCH 1/1 Replace in-place sed in t7502-commit
The in-place mode of sed used in t7502-commit is a non-POSIX extension. That call of sed is replaced by a more portable version using a temporary file.
--- t/t7502-commit.sh | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
t/t7502-commit.sh +3 -1
@@ -166,7 +166,9 @@ test_expect_success 'author different from committer' ' test_cmp expect actual ' -sed -i '$d' expect +mv expect expect.tmp +sed '$d' < expect.tmp > expect +rm -f expect.tmp echo "# Committer: #" >> expect unset GIT_COMMITTER_EMAIL
Signature · 1 line
1.5.5.1.215.g64c0d
Re: [PATCH] Replace in-place sed in t7502-commit
Quoted 3 lines · Marcel Koeppen
The in-place mode of sed used in t7502-commit is a non-POSIX extension. That call of sed is replaced by a more portable version using a temporary file.
Thanks, this fixes a similar issue on FreeBSD (which is probably the same sed).
-Peff
Quoted 2 lines
t/t7502-commit.sh test_expect_success 'author different from committer' ' · line 169
Quoted 2 lines
t/t7502-commit.sh +1
-1-sed -i '$d' expect +sed -i -e '$d' expect
perl -pi -e 's/foo/bar/' ???
GIT already needs perl, so we can re-use it's features savely.
Am 15.05.2008 um 10:58 schrieb Holger Schurig:
Quoted 4 lines
Quoted 2 lines
t/t7502-commit.sh test_expect_success 'author different from committer' ' · line 169
Quoted 2 lines
t/t7502-commit.sh +1
-1-sed -i '$d' expect +sed -i -e '$d' expectperl -pi -e 's/foo/bar/' ???
This does not work with '$d', so we could use sed with a temp instead of the -i extension. Alternatively we could specify the full test fixture instead of editing an old one. This would make the expected results more obvious and the tests would work without assumptions about running order.
Marcel
Quoted 3 lines · Junio C Hamano
But more importantly, as we are serious about portability, we should not be using "sed -i" which is not even in POSIX to begin with.
Is there a way (environment variable, flag) to test if it is POSIX? Or we just have to know?
I'll send a patch to document the "sed -i" issue in Documentation/CodingGuidelines.
Quoted 2 lines
Can we
rewrite these places without using the in-place extension?
Yes, I'll do it soon if nobody beats me.
Santi