qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gabriel Kerneis <gabriel@kerneis.info>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, Gabriel Kerneis <gabriel@kerneis.info>
Subject: [Qemu-devel] [PATCH] config-host.mak: escape configure arguments
Date: Sat,  5 Oct 2013 15:41:32 +0100	[thread overview]
Message-ID: <1380984092-18502-1-git-send-email-gabriel@kerneis.info> (raw)

Escape single quotes and newlines when writing configure arguments
to config-host.mak. This is necessary to allow correct regeneration
by re-executing configure in a shell when config-host.mak becomes
out-of-date.

Signed-off-by: Gabriel Kerneis <gabriel@kerneis.info>
---
 configure | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 23dbaaf..fba7c1f 100755
--- a/configure
+++ b/configure
@@ -3769,7 +3769,11 @@ echo "# Automatically generated by configure - do not modify" >config-all-disas.
 
 echo "# Automatically generated by configure - do not modify" > $config_host_mak
 printf "# Configured with:" >> $config_host_mak
-printf " '%s'" "$0" "$@" >> $config_host_mak
+for arg in "$0" "$@"; do
+  # join each arg on a single line, escaping newlines and single quotes
+  quoted_arg=$(echo "$arg" | sed ":a;N;s/\n/\\\\n/;ba" | sed "s/'/'\\\\''/g")
+  printf " '%s'" "$quoted_arg"
+done >> $config_host_mak
 echo >> $config_host_mak
 
 echo all: >> $config_host_mak
-- 
1.8.4.rc3

             reply	other threads:[~2013-10-05 14:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-05 14:41 Gabriel Kerneis [this message]
2013-10-05 15:54 ` [Qemu-devel] [PATCH] config-host.mak: escape configure arguments Peter Maydell
2013-10-05 22:18   ` Gabriel Kerneis
2013-10-06  5:47     ` Stefan Weil
2013-10-06  7:25       ` Gabriel Kerneis

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=1380984092-18502-1-git-send-email-gabriel@kerneis.info \
    --to=gabriel@kerneis.info \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).