git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] test-lib: simplify '--option=value' parsing
@ 2016-04-22 15:38 SZEDER Gábor
  2016-04-22 18:37 ` Jeff King
  0 siblings, 1 reply; 4+ messages in thread
From: SZEDER Gábor @ 2016-04-22 15:38 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, SZEDER Gábor

To get the 'value' from '--option=value', test-lib.sh parses said
option running 'expr' with a regexp.  This involves a subshell, an
external process, and a lot of non-alphanumeric characters in the
regexp.

Use a much simpler shell parameter expansion instead to do the same.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
 t/test-lib.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index 0b47eb6bb299..8373d5b5c900 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -208,7 +208,7 @@ do
 	-v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
 		verbose=t; shift ;;
 	--verbose-only=*)
-		verbose_only=$(expr "z$1" : 'z[^=]*=\(.*\)')
+		verbose_only=${1#--*=}
 		shift ;;
 	-q|--q|--qu|--qui|--quie|--quiet)
 		# Ignore --quiet under a TAP::Harness. Saying how many tests
@@ -222,15 +222,15 @@ do
 		valgrind=memcheck
 		shift ;;
 	--valgrind=*)
-		valgrind=$(expr "z$1" : 'z[^=]*=\(.*\)')
+		valgrind=${1#--*=}
 		shift ;;
 	--valgrind-only=*)
-		valgrind_only=$(expr "z$1" : 'z[^=]*=\(.*\)')
+		valgrind_only=${1#--*=}
 		shift ;;
 	--tee)
 		shift ;; # was handled already
 	--root=*)
-		root=$(expr "z$1" : 'z[^=]*=\(.*\)')
+		root=${1#--*=}
 		shift ;;
 	--chain-lint)
 		GIT_TEST_CHAIN_LINT=1
-- 
2.8.1.99.g5d5236f

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

end of thread, other threads:[~2016-04-22 20:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-22 15:38 [PATCH] test-lib: simplify '--option=value' parsing SZEDER Gábor
2016-04-22 18:37 ` Jeff King
2016-04-22 20:32   ` [PATCH v2] " SZEDER Gábor
2016-04-22 20:54   ` [PATCH] " Junio C Hamano

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).