Skip to content

Commit 0ff7410

Browse files
szedergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6a66362 commit 0ff7410

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

t/test-lib.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@ do
202202
}
203203
run_list=$1; shift ;;
204204
--run=*)
205-
run_list=$(expr "z$1" : 'z[^=]*=\(.*\)'); shift ;;
205+
run_list=${1#--*=}; shift ;;
206206
-h|--h|--he|--hel|--help)
207207
help=t; shift ;;
208208
-v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
209209
verbose=t; shift ;;
210210
--verbose-only=*)
211-
verbose_only=$(expr "z$1" : 'z[^=]*=\(.*\)')
211+
verbose_only=${1#--*=}
212212
shift ;;
213213
-q|--q|--qu|--qui|--quie|--quiet)
214214
# Ignore --quiet under a TAP::Harness. Saying how many tests
@@ -222,15 +222,15 @@ do
222222
valgrind=memcheck
223223
shift ;;
224224
--valgrind=*)
225-
valgrind=$(expr "z$1" : 'z[^=]*=\(.*\)')
225+
valgrind=${1#--*=}
226226
shift ;;
227227
--valgrind-only=*)
228-
valgrind_only=$(expr "z$1" : 'z[^=]*=\(.*\)')
228+
valgrind_only=${1#--*=}
229229
shift ;;
230230
--tee)
231231
shift ;; # was handled already
232232
--root=*)
233-
root=$(expr "z$1" : 'z[^=]*=\(.*\)')
233+
root=${1#--*=}
234234
shift ;;
235235
--chain-lint)
236236
GIT_TEST_CHAIN_LINT=1

0 commit comments

Comments
 (0)