From 169e1597f91d81d612c5a63aaab26beea76859da Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 9 Oct 2017 17:32:11 +0800 Subject: [PATCH] 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 --- src/vstart.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/vstart.sh b/src/vstart.sh index 1fd78eec9e1..8e1b90125ae 100755 --- a/src/vstart.sh +++ b/src/vstart.sh @@ -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 $* "$@" }