summaryrefslogtreecommitdiff
path: root/t/test-lib-functions.sh
diff options
context:
space:
mode:
authorSZEDER Gábor <szeder.dev@gmail.com>2019-02-11 19:58:03 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-02-11 22:34:36 (GMT)
commit7d661e5ed16dca303d7898f5ab0cc2ffc69e0499 (patch)
tree4469d0e973a2ceeaaa237940979c107dd2998cb1 /t/test-lib-functions.sh
parent76e27fbfd92030a685a591cc89f63de2cc37f540 (diff)
downloadgit-7d661e5ed16dca303d7898f5ab0cc2ffc69e0499.zip
git-7d661e5ed16dca303d7898f5ab0cc2ffc69e0499.tar.gz
git-7d661e5ed16dca303d7898f5ab0cc2ffc69e0499.tar.bz2
test-lib: fix non-portable pattern bracket expressions
Use a '!' character to start a non-matching pattern bracket expression, as specified by POSIX in Shell Command Language section 2.13.1 Patterns Matching a Single Character [1]. I used '^' instead in three places in the previous three commits, to verify that the arguments of the '--stress=' and '--stress-limit=' options and the values of various '*_PORT' environment variables are valid numbers. With certain shells, at least with dash (upstream and in Ubuntu 14.04) and mksh, this led to various undesired behaviors: # error message in case of a valid number $ ~/src/dash/src/dash ./t3903-stash.sh --stress=8 error: --stress=<N> requires the number of jobs to run # not the expected error message $ ~/src/dash/src/dash ./t3903-stash.sh --stress=foo ./t3903-stash.sh: 238: test: Illegal number: foo # no error message at all?! $ mksh ./t3903-stash.sh --stress=foo $ echo $? 0 Some other shells, e.g. Bash (even in posix mode), ksh, dash in Ubuntu 16.04 or later, are apparently happy to accept '^' just as well. [1] http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_13 Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/test-lib-functions.sh')
-rw-r--r--t/test-lib-functions.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 92cf8f8..969e2ba 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -1289,7 +1289,7 @@ test_set_port () {
port=$(($port + 10000))
fi
;;
- *[^0-9]*|0*)
+ *[!0-9]*|0*)
error >&7 "invalid port number: $port"
;;
*)