All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-trivial@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-trivial] [PATCH] Quote extra_cflags in config-host.mak
Date: Wed, 11 Sep 2013 09:55:52 -0600	[thread overview]
Message-ID: <52309288.8000100@redhat.com> (raw)
In-Reply-To: <523083EF.7050203@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1162 bytes --]

On 09/11/2013 08:53 AM, Paolo Bonzini wrote:
> 
> printf "# Configured with:" >> $config_host_mak
> printf " '%s'" "$0" "$@" >> $config_host_mak
> 
> Something like
> 
> for arg in "$0" "$@"; do
>    quoted_arg=$(echo "$i" | sed 's/[$\\"]/\\&/g')

Won't work as written: mismatch between $arg vs. $i.

That missed ` - but do we expect anyone to pass a literal ` as one of
their arguments?  Also, it strips any literal trailing newlines in the
arguments.

>    printf ' "%s"' "$quoted_arg"
> done >> $config_host_mak
> 
> could replace the second line.  Adding Eric Blake in case he knows some
> extra trick.

Nope, no good portable tricks for this.  But to address the (corner
case) issues I mentioned above, it might be worth using '' rather than
"" quoting; as well as embed a trailing space to guarantee no trailing
newline:

for arg in "$0" "$@"; do
    quoted_arg=$(echo "$arg " | sed "s/'/'\\''/g')
    printf "'%s'" "$quoted_arg"
done >> $config_host_mak

if you don't mind a trailing space in the output file.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]

      parent reply	other threads:[~2013-09-11 15:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-11 13:41 [Qemu-trivial] [PATCH] Quote extra_cflags in config-host.mak Gabriel Kerneis
2013-09-11 14:01 ` Paolo Bonzini
2013-09-11 14:42   ` Gabriel Kerneis
2013-09-11 14:53     ` Paolo Bonzini
2013-09-11 15:01       ` Gabriel Kerneis
2013-09-11 15:06         ` Paolo Bonzini
2013-09-11 15:16           ` [Qemu-trivial] [Qemu-devel] " Gabriel Kerneis
2013-09-11 15:23             ` Gabriel Kerneis
2013-09-11 15:29               ` Paolo Bonzini
2013-09-11 15:14         ` Gabriel Kerneis
2013-09-11 15:55       ` Eric Blake [this message]

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=52309288.8000100@redhat.com \
    --to=eblake@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.