Skip to contentSkip to conversation

t7403-*.sh: Avoid use of the nonportable '==' operator

PATCH In review Ramsay Jones 3 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 t7403-*.sh: Avoid use of the nonportable '==' operator

Some shells, including dash, do not support using the '==' string equality operator. This results in the failure of tests 7-12 with 'test' complaining of an "unexpected operator".

In order to suppress the errors, we replace the '==' operator with '=', which must be supported by any POSIX shell.

---

Hi Jon,

If you need to re-roll your patches from the 'js/submodule-relative' branch (commits 3f4542e and efa4c90), could you please squash this fix into them.

Thanks!

ATB,
Ramsay Jones

 t/t7403-submodule-sync.sh |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
t/t7403-submodule-sync.sh +6 -6
index 583fe21..3d85739 100755
@@ -93,7 +93,7 @@ test_expect_success '"git submodule sync" handles origin URL of the form foo' '
 	 git remote set-url origin foo
 	 git submodule sync &&
 	(cd submodule &&
-	 test "$(git config remote.origin.url)" == "../submodule"
+	 test "$(git config remote.origin.url)" = "../submodule"
 	)
 	)
 '
@@ -103,7 +103,7 @@ test_expect_success '"git submodule sync" handles origin URL of the form foo/bar
 	 git remote set-url origin foo/bar
 	 git submodule sync &&
 	(cd submodule &&
-	 test "$(git config remote.origin.url)" == "../foo/submodule"
+	 test "$(git config remote.origin.url)" = "../foo/submodule"
 	)
 	)
 '
@@ -113,7 +113,7 @@ test_expect_success '"git submodule sync" handles origin URL of the form ./foo'
 	 git remote set-url origin ./foo
 	 git submodule sync &&
 	(cd submodule &&
-	 test "$(git config remote.origin.url)" == "../submodule"
+	 test "$(git config remote.origin.url)" = "../submodule"
 	)
 	)
 '
@@ -123,7 +123,7 @@ test_expect_success '"git submodule sync" handles origin URL of the form ./foo/b
 	 git remote set-url origin ./foo/bar
 	 git submodule sync &&
 	(cd submodule &&
-	 test "$(git config remote.origin.url)" == "../foo/submodule"
+	 test "$(git config remote.origin.url)" = "../foo/submodule"
 	)
 	)
 '
@@ -133,7 +133,7 @@ test_expect_success '"git submodule sync" handles origin URL of the form ../foo'
 	 git remote set-url origin ../foo
 	 git submodule sync &&
 	(cd submodule &&
-	 test "$(git config remote.origin.url)" == "../../submodule"
+	 test "$(git config remote.origin.url)" = "../../submodule"
 	)
 	)
 '
@@ -143,7 +143,7 @@ test_expect_success '"git submodule sync" handles origin URL of the form ../foo/
 	 git remote set-url origin ../foo/bar
 	 git submodule sync &&
 	(cd submodule &&
-	 test "$(git config remote.origin.url)" == "../../foo/submodule"
+	 test "$(git config remote.origin.url)" = "../../foo/submodule"
 	)
 	)
 '
Signature · 1 line
1.7.10
#1 lore raw
Quoted 3 lines · Ramsay Jones

Some shells, including dash, do not support using the '==' string equality operator. This results in the failure of tests 7-12 with 'test' complaining of an "unexpected operator".

Thanks. You do not have to single-out dash.
A shell script that uses "test $a == $b" is *buggy* and not conforming to POSIX.

#2 lore raw
Quoted 9 lines · Junio C Hamano
Quoted 3 lines · Ramsay Jones

Some shells, including dash, do not support using the '==' string equality operator. This results in the failure of tests 7-12 with 'test' complaining of an "unexpected operator".

Thanks.  You do not have to single-out dash.
A shell script that uses "test $a == $b" is *buggy* and not conforming to POSIX.

Yep. This slipped through because I happen to have reconfigured my /bin/sh to point to bash (frrom Ubuntu's default of dash) because of an issue with a product installation script. This shouldn't have been a problem if bash's POSIX mode was strict about rejecting == but bash doesn't seem to be strict about this.

Anyway, I have reverted /bin/sh to refer to dash so hopefully I won't be caught by this in future.

jon.

#3 lore raw
In reply to Ramsay Jones
Quoted 8 lines · Ramsay Jones

Some shells, including dash, do not support using the '==' string equality operator. This results in the failure of tests 7-12 with 'test' complaining of an "unexpected operator".

In order to suppress the errors, we replace the '==' operator with '=', which must be supported by any POSIX shell.

Thanks. I take it than an example of such a shell is dash?

BTW: the next iteration is more of a re-write than a re-roll because I noticed some other issues (e.g. preventing git://hostname/repo being silently transformed to git://subrepo in the case of a pathological use of a submodule URL of the form ../../subrepo) and fixing this required a change that required a more extensive suite of tests.

jon.