test-lib: simplify '--option=value' parsing

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 POSIX-defined shell parameter expansion instead to do the same. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

SZEDER Gábor committed Apr 22, 2016 at 22:32 UTC 0ff74101dcc6050190b5f55da1b79a3df1611804
1 file changed +5 -5
t/test-lib.sh
+5 -5
@@ -202,13 +202,13 @@ do
202 }
203 run_list=$1; shift ;;
204 --run=*)
205 - run_list=$(expr "z$1" : 'z[^=]*=\(.*\)'); shift ;;
205 + run_list=${1#--*=}; shift ;;
206 -h|--h|--he|--hel|--help)
207 help=t; shift ;;
208 -v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
209 verbose=t; shift ;;
210 --verbose-only=*)
211 - verbose_only=$(expr "z$1" : 'z[^=]*=\(.*\)')
211 + verbose_only=${1#--*=}
212 shift ;;
213 -q|--q|--qu|--qui|--quie|--quiet)
214 # Ignore --quiet under a TAP::Harness. Saying how many tests
@@ -222,15 +222,15 @@ do
222 valgrind=memcheck
223 shift ;;
224 --valgrind=*)
225 - valgrind=$(expr "z$1" : 'z[^=]*=\(.*\)')
225 + valgrind=${1#--*=}
226 shift ;;
227 --valgrind-only=*)
228 - valgrind_only=$(expr "z$1" : 'z[^=]*=\(.*\)')
228 + valgrind_only=${1#--*=}
229 shift ;;
230 --tee)
231 shift ;; # was handled already
232 --root=*)
233 - root=$(expr "z$1" : 'z[^=]*=\(.*\)')
233 + root=${1#--*=}
234 shift ;;
235 --chain-lint)
236 GIT_TEST_CHAIN_LINT=1