Skip to content

Commit f0c4320

Browse files
committed
shellcheck: on entrypoint
Report was: In docker-entrypoint.sh line 67: mysql=( docker_process_sql ) ^---^ SC2034: mysql appears unused. Verify use (or export if used externally). In docker-entrypoint.sh line 81: . "$f" ^--^ SC1090: ShellCheck can't follow non-constant source. Use a directive to specify location. In docker-entrypoint.sh line 149: if [ -z "$MARIADB_ROOT_PASSWORD" -a -z "$MARIADB_ALLOW_EMPTY_ROOT_PASSWORD" -a -z "$MARIADB_RANDOM_ROOT_PASSWORD" ]; then ^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. ^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. In docker-entrypoint.sh line 228: passfileArgs=() ^----------^ SC2034: passfileArgs appears unused. Verify use (or export if used externally). In docker-entrypoint.sh line 231: MYSQL_PWD= docker_exec_client "$@" ^-- SC1007: Remove space after = if trying to assign a value (for empty string, use var='' ... ). In docker-entrypoint.sh line 366: exec gosu mysql "$BASH_SOURCE" "$@" ^----------^ SC2128: Expanding an array without an index only gives the first element.
1 parent fbcf2d2 commit f0c4320

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

docker-entrypoint.sh

+7-4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ _is_sourced() {
6464
# process initializer files, based on file extensions
6565
docker_process_init_files() {
6666
# mysql here for backwards compatibility "${mysql[@]}"
67+
# ShellCheck: mysql appears unused. Verify use (or export if used externally)
68+
# shellcheck disable=SC2034
6769
mysql=( docker_process_sql )
6870

6971
echo
@@ -78,6 +80,8 @@ docker_process_init_files() {
7880
"$f"
7981
else
8082
mysql_note "$0: sourcing $f"
83+
# ShellCheck can't follow non-constant source. Use a directive to specify location.
84+
# shellcheck disable=SC1090
8185
. "$f"
8286
fi
8387
;;
@@ -146,7 +150,7 @@ docker_temp_server_stop() {
146150

147151
# Verify that the minimally required password settings are set for new databases.
148152
docker_verify_minimum_env() {
149-
if [ -z "$MARIADB_ROOT_PASSWORD" -a -z "$MARIADB_ALLOW_EMPTY_ROOT_PASSWORD" -a -z "$MARIADB_RANDOM_ROOT_PASSWORD" ]; then
153+
if [ -z "$MARIADB_ROOT_PASSWORD" ] && [ -z "$MARIADB_ALLOW_EMPTY_ROOT_PASSWORD" ] && [ -z "$MARIADB_RANDOM_ROOT_PASSWORD" ]; then
150154
mysql_error $'Database is uninitialized and password option is not specified\n\tYou need to specify one of MARIADB_ROOT_PASSWORD, MARIADB_ALLOW_EMPTY_ROOT_PASSWORD and MARIADB_RANDOM_ROOT_PASSWORD'
151155
fi
152156
}
@@ -225,10 +229,9 @@ docker_exec_client() {
225229
# ie: docker_process_sql --database=mydb <<<'INSERT ...'
226230
# ie: docker_process_sql --dont-use-mysql-root-password --database=mydb <my-file.sql
227231
docker_process_sql() {
228-
passfileArgs=()
229232
if [ '--dont-use-mysql-root-password' = "$1" ]; then
230233
shift
231-
MYSQL_PWD= docker_exec_client "$@"
234+
MYSQL_PWD='' docker_exec_client "$@"
232235
else
233236
MYSQL_PWD=$MARIADB_ROOT_PASSWORD docker_exec_client "$@"
234237
fi
@@ -363,7 +366,7 @@ _main() {
363366
# If container is started as root user, restart as dedicated mysql user
364367
if [ "$(id -u)" = "0" ]; then
365368
mysql_note "Switching to dedicated user 'mysql'"
366-
exec gosu mysql "$BASH_SOURCE" "$@"
369+
exec gosu mysql "${BASH_SOURCE[0]}" "$@"
367370
fi
368371

369372
# there's no database, so it needs to be initialized

0 commit comments

Comments
 (0)