git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] shell portability: Use sed instead of non-portable variable expansion
@ 2011-09-05  5:11 Naohiro Aota
  2011-09-05  7:03 ` Johannes Sixt
  2011-09-05  7:09 ` Junio C Hamano
  0 siblings, 2 replies; 19+ messages in thread
From: Naohiro Aota @ 2011-09-05  5:11 UTC (permalink / raw)
  To: git; +Cc: gitster, tarmigan+git

Variable expansions like "${foo#bar}" or "${foo%bar}" doesn't work on
shells like FreeBSD sh and they made the test to fail. This patch
replace such variable expansions with sed.

Signed-off-by: Naohiro Aota <naota@elisp.net>
---

Testing on FreeBSD failed because of this "bash-ism". After applying
this patch, I've verified the test to pass on FreeBSD. (and it worked
well also with GNU sed)

 t/t5560-http-backend-noserver.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/t5560-http-backend-noserver.sh b/t/t5560-http-backend-noserver.sh
index 0ad7ce0..c8237ef 100755
--- a/t/t5560-http-backend-noserver.sh
+++ b/t/t5560-http-backend-noserver.sh
@@ -9,8 +9,8 @@ test_have_prereq MINGW && export GREP_OPTIONS=-U
 
 run_backend() {
 	echo "$2" |
-	QUERY_STRING="${1#*\?}" \
-	PATH_TRANSLATED="$HTTPD_DOCUMENT_ROOT_PATH/${1%%\?*}" \
+	QUERY_STRING=$(echo "$1"|sed -e 's/^[^?]*?\(.*\)$/\1/') \
+	PATH_TRANSLATED="$HTTPD_DOCUMENT_ROOT_PATH/$(echo "$1"|sed -e 's/^\([^?]*\)?.*$/\1/')" \
 	git http-backend >act.out 2>act.err
 }
 
-- 
1.7.6

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2011-09-06 20:30 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-05  5:11 [PATCH] shell portability: Use sed instead of non-portable variable expansion Naohiro Aota
2011-09-05  7:03 ` Johannes Sixt
2011-09-05  7:15   ` Junio C Hamano
2011-09-05  7:35     ` Johannes Sixt
2011-09-05  7:45       ` Junio C Hamano
2011-09-05  8:16         ` Johannes Sixt
2011-09-05  8:21           ` Johannes Sixt
2011-09-05  7:55   ` Naohiro Aota
2011-09-05  7:09 ` Junio C Hamano
2011-09-05  7:54   ` Johannes Sixt
2011-09-05  8:11     ` Junio C Hamano
2011-09-05  8:22     ` Junio C Hamano
2011-09-06 19:09   ` [PATCH] Makefile: abort on shells that do not support ${parameter%word} expansion Brandon Casey
2011-09-06 19:32     ` Brandon Casey
2011-09-06 20:30       ` Brandon Casey
2011-09-06 20:01     ` Junio C Hamano
2011-09-06 20:09       ` Brandon Casey
2011-09-06 20:03     ` Junio C Hamano
2011-09-06 20:20       ` Brandon Casey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).