fix: do not interprete leading hyphens in commands as "echo" arguments

Previously an input token with a leading hyphen (e.g. "-n") could be
inadvertently interpreted by "echo" instead of being taken literally.

No further damage was possible, but this would have been unexpected.
This commit is contained in:
Lars Kruse 2021-07-14 13:29:04 +02:00
parent 1f147fcb1c
commit 32d4362888

View file

@ -125,9 +125,9 @@ HOSTNAME=$( { hostname -f || hostname || cat /proc/sys/kernel/hostname || echo "
echo "# munin node at $HOSTNAME" echo "# munin node at $HOSTNAME"
while read -r arg0 arg1 while read -r arg0 arg1
do do
arg0=$(echo "$arg0" | xargs) arg0=$(printf '%s\n' "$arg0" | xargs)
arg1=$(echo "$arg1" | xargs) arg1=$(printf '%s\n' "$arg1" | xargs)
if ! echo "$FUNCTIONS" | grep -qwF "$arg0"; then if ! echo "$FUNCTIONS" | grep -qwF -- "$arg0"; then
echo "# Unknown command. Try $(echo "$FUNCTIONS" | sed -e 's/\( [[:alpha:]]\{1,\}\)/,\1/g' -e 's/,\( [[:alpha:]]\{1,\}\)$/ or\1/')" echo "# Unknown command. Try $(echo "$FUNCTIONS" | sed -e 's/\( [[:alpha:]]\{1,\}\)/,\1/g' -e 's/,\( [[:alpha:]]\{1,\}\)$/ or\1/')"
elif [ -n "$arg0" ]; then elif [ -n "$arg0" ]; then
"do_$arg0" "$arg1" "do_$arg0" "$arg1"