From dd468bf8fde3c31d313667d9192dbe5c74e71ffc Mon Sep 17 00:00:00 2001 From: Krzysztof Czajka Date: Fri, 24 Nov 2023 20:05:59 +0100 Subject: [PATCH 1/2] minor fixes for shellcheck warnings/errors --- build/ps-entry.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build/ps-entry.sh b/build/ps-entry.sh index 7b443fdb9c..fceac98de5 100755 --- a/build/ps-entry.sh +++ b/build/ps-entry.sh @@ -19,7 +19,7 @@ if [[ $originalArgOne == mongo* ]] && [ "$(id -u)" = '0' ]; then chown --dereference mongodb "/proc/$$/fd/1" "/proc/$$/fd/2" || : # ignore errors thanks to https://github.com/docker-library/mongo/issues/149 - exec gosu mongodb:1001 "$BASH_SOURCE" "$@" + exec gosu mongodb:1001 "${BASH_SOURCE[0]}" "$@" fi # you should use numactl to start your mongod instances, including the config servers, mongos instances, and any clients. @@ -88,7 +88,7 @@ _mongod_hack_get_arg_val() { return 0 ;; "$checkArg"=*) - echo "${arg#$checkArg=}" + echo "${arg#"$checkArg"=}" return 0 ;; esac @@ -398,6 +398,7 @@ if [ "$originalArgOne" = 'mongod' ]; then case "$f" in *.sh) echo "$0: running $f" + # shellcheck source=/dev/null . "$f" ;; *.js) From df36868442910212218b3ccdc43dffc63b77bffc Mon Sep 17 00:00:00 2001 From: Krzysztof Czajka Date: Fri, 24 Nov 2023 17:42:45 +0100 Subject: [PATCH 2/2] K8SPSMDB-1018: fix incorrect Bash quoting in ps-entry.sh script The variable with `numactl` command was quoted, so it was added to the list of positional parameters as a quoted string, therefore causing `exec "$@"` call to fail. This commit changes the variable to an array, so that it can be properly quoted and does not trigger Shellcheck SC-2086 warning. --- build/ps-entry.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/ps-entry.sh b/build/ps-entry.sh index fceac98de5..b680571aa9 100755 --- a/build/ps-entry.sh +++ b/build/ps-entry.sh @@ -25,9 +25,9 @@ fi # you should use numactl to start your mongod instances, including the config servers, mongos instances, and any clients. # https://docs.mongodb.com/manual/administration/production-notes/#configuring-numa-on-linux if [[ $originalArgOne == mongo* ]]; then - numa='numactl --interleave=all' - if $numa true &>/dev/null; then - set -- "$numa" "$@" + numa=(numactl --interleave=all) + if "${numa[@]}" true &>/dev/null; then + set -- "${numa[@]}" "$@" fi fi