Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: stefanha@linux.vnet.ibm.com (Stefan Hajnoczi)
Subject: [ltt-dev] [PATCH] usttrace: allow spaces in command-line arguments
Date: Wed, 16 Nov 2011 10:00:18 +0000	[thread overview]
Message-ID: <1321437618-1416-1-git-send-email-stefanha@linux.vnet.ibm.com> (raw)

The usttrace uses $*, which expands arguments without preserving their
boundaries.  This causes arguments that include spaces to be mangled:

[0] "echo"
[1] "hello world"

becomes:

[0] "echo"
[1] "hello"
[2] "world"

Use "$@" instead so that argument boundaries are preserved.

Signed-off-by: Stefan Hajnoczi <stefanha at linux.vnet.ibm.com>
---
 usttrace |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/usttrace b/usttrace
index e76dae7..d1a6e5f 100755
--- a/usttrace
+++ b/usttrace
@@ -85,16 +85,13 @@ if [ -n "$where" ]; then
 	exit 0
 fi
 
-# Prepare vars
-CMD=$*
-
 # Validate input
 if [ -z "$HOME" ];
 then
 	error "no home specified"
 fi
 
-if [ -z "$CMD" ];
+if [ -z "$*" ];
 then
 	error "no command specified"
 	usage;
@@ -196,7 +193,7 @@ fi
     fi
 
 # Execute the command
-    $CMD 2>&1
+    "$@" 2>&1
 ) | tee "$OUTDIR/app.log"
 
 ## Because of the keepalive mechanism, we're sure that by the time
-- 
1.7.7.1




             reply	other threads:[~2011-11-16 10:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-16 10:00 Stefan Hajnoczi [this message]
2011-11-16 12:17 ` Mathieu Desnoyers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1321437618-1416-1-git-send-email-stefanha@linux.vnet.ibm.com \
    --to=stefanha@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox