]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
vstart.sh: quote command only when necessary 18181/head
authorKefu Chai <kchai@redhat.com>
Mon, 9 Oct 2017 09:32:11 +0000 (17:32 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 9 Oct 2017 09:42:00 +0000 (17:42 +0800)
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>
src/vstart.sh

index 1fd78eec9e133aeae0f1668b275acff9540851c6..8e1b90125ae31ef1ba5228b8a4bf3fffbb4d07a5 100755 (executable)
@@ -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 $*
     "$@"
 }