vstart.sh: quote command only when necessary

we quote the command args, so it's easier to copy and paste it to rerun
the command. but it's annoying to read the echod command with the
quotes. so quote them only if the arg has space in it, it'd easier for
eyes.

Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2017-10-09 17:32:11 +08:00
parent 3b9564f667
commit 169e1597f9

View File

@ -366,13 +366,24 @@ fi
ARGS="-c $conf_fn"
quoted_print() {
for s in "$@"; do
if [[ "$s" =~ \ ]]; then
printf -- "'%s' " "$s"
else
printf -- "$s "
fi
done
printf '\n'
}
prunb() {
printf "'%s' " "$@"; echo '&'
quoted_print $* '&'
"$@" &
}
prun() {
printf "'%s' " "$@"; echo
quoted_print $*
"$@"
}