File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change 88# - WP_CLI_TEST_DBUSER is the user that the tests run under (defaults to "wp_cli_test").
99# - WP_CLI_TEST_DBPASS is the password to use for the above user (defaults to "password1").
1010
11+ # POSIX compliant function to check if a string is numeric.
12+ is_numeric () {
13+ case $1 in
14+ ' ' |* [!0-9]* ) return 1;; # returns 1 if not numeric
15+ * ) return 0;; # returns 0 if numeric
16+ esac
17+ }
18+
1119HOST=localhost
1220PORT=" "
1321HOST_STRING=' '
@@ -16,9 +24,14 @@ if [ -n "${WP_CLI_TEST_DBHOST}" ]; then
1624 (* :* ) HOST=${WP_CLI_TEST_DBHOST%:* } PORT=${WP_CLI_TEST_DBHOST##*: } ;;
1725 (* ) HOST=${WP_CLI_TEST_DBHOST} ;;
1826 esac
19- HOST_STRING=" -h${HOST} "
20- if [ -n " ${PORT} " ]; then
21- HOST_STRING=" ${HOST_STRING} -P${PORT} --protocol=tcp"
27+ HOST_STRING=" -h${HOST} "
28+ if [ -n " ${PORT} " ]; then
29+ # If the port is not numeric, then we assume it is a socket path.
30+ if is_numeric " ${PORT} " ; then
31+ HOST_STRING=" ${HOST_STRING} -P${PORT} --protocol=tcp"
32+ else
33+ HOST_STRING=" ${HOST_STRING} --socket=${PORT} "
34+ fi
2235 fi
2336fi
2437
You can’t perform that action at this time.
0 commit comments