From: Kefu Chai Date: Mon, 9 Oct 2017 09:32:11 +0000 (+0800) Subject: vstart.sh: quote command only when necessary X-Git-Tag: v13.0.1~432^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=169e1597f91d81d612c5a63aaab26beea76859da;p=ceph.git 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 --- diff --git a/src/vstart.sh b/src/vstart.sh index 1fd78eec9e133..8e1b90125ae31 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 $* "$@" }