[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-trivial] [PATCH] Quote extra_cflags in config-host.mak
From: |
Eric Blake |
Subject: |
Re: [Qemu-trivial] [PATCH] Quote extra_cflags in config-host.mak |
Date: |
Wed, 11 Sep 2013 09:55:52 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8 |
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
signature.asc
Description: OpenPGP digital signature
- [Qemu-trivial] [PATCH] Quote extra_cflags in config-host.mak, Gabriel Kerneis, 2013/09/11
- Re: [Qemu-trivial] [PATCH] Quote extra_cflags in config-host.mak, Paolo Bonzini, 2013/09/11
- Re: [Qemu-trivial] [PATCH] Quote extra_cflags in config-host.mak, Gabriel Kerneis, 2013/09/11
- Re: [Qemu-trivial] [PATCH] Quote extra_cflags in config-host.mak, Paolo Bonzini, 2013/09/11
- Re: [Qemu-trivial] [PATCH] Quote extra_cflags in config-host.mak, Gabriel Kerneis, 2013/09/11
- Re: [Qemu-trivial] [PATCH] Quote extra_cflags in config-host.mak, Paolo Bonzini, 2013/09/11
- Re: [Qemu-trivial] [Qemu-devel] [PATCH] Quote extra_cflags in config-host.mak, Gabriel Kerneis, 2013/09/11
- Re: [Qemu-trivial] [Qemu-devel] [PATCH] Quote extra_cflags in config-host.mak, Gabriel Kerneis, 2013/09/11
- Re: [Qemu-trivial] [Qemu-devel] [PATCH] Quote extra_cflags in config-host.mak, Paolo Bonzini, 2013/09/11
- Re: [Qemu-trivial] [Qemu-devel] [PATCH] Quote extra_cflags in config-host.mak, Gabriel Kerneis, 2013/09/11
- Re: [Qemu-trivial] [PATCH] Quote extra_cflags in config-host.mak,
Eric Blake <=