Skip to content

Commit ca70e0c

Browse files
wpt1313hors
andauthored
K8SPSMDB-1018: fix incorrect Bash quoting in ps-entry.sh script (#1382)
* minor fixes for shellcheck warnings/errors * 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. --------- Co-authored-by: Viacheslav Sarzhan <slava.sarzhan@percona.com>
1 parent 63dfcfe commit ca70e0c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

build/ps-entry.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ if [[ $originalArgOne == mongo* ]] && [ "$(id -u)" = '0' ]; then
1919
chown --dereference mongodb "/proc/$$/fd/1" "/proc/$$/fd/2" || :
2020
# ignore errors thanks to https://github.com/docker-library/mongo/issues/149
2121

22-
exec gosu mongodb:1001 "$BASH_SOURCE" "$@"
22+
exec gosu mongodb:1001 "${BASH_SOURCE[0]}" "$@"
2323
fi
2424

2525
# you should use numactl to start your mongod instances, including the config servers, mongos instances, and any clients.
2626
# https://docs.mongodb.com/manual/administration/production-notes/#configuring-numa-on-linux
2727
if [[ $originalArgOne == mongo* ]]; then
28-
numa='numactl --interleave=all'
29-
if $numa true &>/dev/null; then
30-
set -- "$numa" "$@"
28+
numa=(numactl --interleave=all)
29+
if "${numa[@]}" true &>/dev/null; then
30+
set -- "${numa[@]}" "$@"
3131
fi
3232
fi
3333

@@ -88,7 +88,7 @@ _mongod_hack_get_arg_val() {
8888
return 0
8989
;;
9090
"$checkArg"=*)
91-
echo "${arg#$checkArg=}"
91+
echo "${arg#"$checkArg"=}"
9292
return 0
9393
;;
9494
esac
@@ -398,6 +398,7 @@ if [ "$originalArgOne" = 'mongod' ]; then
398398
case "$f" in
399399
*.sh)
400400
echo "$0: running $f"
401+
# shellcheck source=/dev/null
401402
. "$f"
402403
;;
403404
*.js)

0 commit comments

Comments
 (0)