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
1 changed files with 3 additions and 3 deletions

View File

@ -125,9 +125,9 @@ HOSTNAME=$( { hostname -f || hostname || cat /proc/sys/kernel/hostname || echo "
echo "# munin node at $HOSTNAME"
while read -r arg0 arg1
do
arg0=$(echo "$arg0" | xargs)
arg1=$(echo "$arg1" | xargs)
if ! echo "$FUNCTIONS" | grep -qwF "$arg0"; then
arg0=$(printf '%s\n' "$arg0" | xargs)
arg1=$(printf '%s\n' "$arg1" | xargs)
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/')"
elif [ -n "$arg0" ]; then
"do_$arg0" "$arg1"