Skip to content

Commit 9f1eb5d

Browse files
committed
fix(createdb): use case instead of expr for portability
Using 'case' avoids potential issues with 'expr' and special characters on different shells/OSs.
1 parent a167a73 commit 9f1eb5d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/createdb.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ set_dbuserpass () {
5050
}
5151

5252
add_granthost () {
53-
if expr "x$1" : 'x[-a-zA-Z0-9.*%_][-a-zA-Z0-9.*%_]*$' >/dev/null; then
54-
granthosts="$granthosts $1"
55-
else
53+
case "$1" in
54+
""|*[!a-zA-Z0-9.*%_]*)
5655
echo "Expected --grant-host=HOSTNAME" 1>&2
57-
usage
58-
fi
56+
usage;;
57+
*)
58+
granthosts="$granthosts $1";;
59+
esac
5960
}
6061

6162
PROG=$0

0 commit comments

Comments
 (0)