qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] configure: Quote the configure args printed in config.log
@ 2012-03-07 12:16 Peter Maydell
  2012-03-07 12:40 ` Stefan Hajnoczi
  2012-03-07 17:14 ` Avi Kivity
  0 siblings, 2 replies; 8+ messages in thread
From: Peter Maydell @ 2012-03-07 12:16 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial

Use the same mechanism we use for printing the configure command
line to config-host.mak to print it to config.log. This fixes a
bug where the config.log version didn't quote arguments with spaces.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
If I'd noticed when I was adding the banner to config.log that we already
printed this in config-host.mak I'd have done it this way to start with...

 configure |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/configure b/configure
index a5eb832..1b63436 100755
--- a/configure
+++ b/configure
@@ -22,7 +22,9 @@ rm -f config.log
 
 # Print a helpful header at the top of config.log
 echo "# QEMU configure log $(date)" >> config.log
-echo "# produced by $0 $*" >> config.log
+printf "# Configured with:" >> config.log
+printf " '%s'" "$0" "$@" >> config.log
+echo >> config.log
 echo "#" >> config.log
 
 compile_object() {
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH] configure: Quote the configure args printed in config.log
  2012-03-07 12:16 [Qemu-devel] [PATCH] configure: Quote the configure args printed in config.log Peter Maydell
@ 2012-03-07 12:40 ` Stefan Hajnoczi
  2012-03-07 17:06   ` Eric Blake
  2012-03-07 17:09   ` Peter Maydell
  2012-03-07 17:14 ` Avi Kivity
  1 sibling, 2 replies; 8+ messages in thread
From: Stefan Hajnoczi @ 2012-03-07 12:40 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-trivial, qemu-devel

On Wed, Mar 7, 2012 at 12:16 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> Use the same mechanism we use for printing the configure command
> line to config-host.mak to print it to config.log. This fixes a
> bug where the config.log version didn't quote arguments with spaces.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> If I'd noticed when I was adding the banner to config.log that we already
> printed this in config-host.mak I'd have done it this way to start with...
>
>  configure |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/configure b/configure
> index a5eb832..1b63436 100755
> --- a/configure
> +++ b/configure
> @@ -22,7 +22,9 @@ rm -f config.log
>
>  # Print a helpful header at the top of config.log
>  echo "# QEMU configure log $(date)" >> config.log
> -echo "# produced by $0 $*" >> config.log
> +printf "# Configured with:" >> config.log
> +printf " '%s'" "$0" "$@" >> config.log

You use an interesting feature of printf(1)- it applies the (short)
format string as long as there are arguments.  I checked that this is
in the specification:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html

Thanks, applied to the trivial patches tree:
https://github.com/stefanha/qemu/commits/trivial-patches

Stefan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH] configure: Quote the configure args printed in config.log
  2012-03-07 12:40 ` Stefan Hajnoczi
@ 2012-03-07 17:06   ` Eric Blake
  2012-03-07 17:08     ` Peter Maydell
  2012-03-07 17:09   ` Peter Maydell
  1 sibling, 1 reply; 8+ messages in thread
From: Eric Blake @ 2012-03-07 17:06 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: qemu-trivial, Peter Maydell, qemu-devel

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

On 03/07/2012 05:40 AM, Stefan Hajnoczi wrote:
> On Wed, Mar 7, 2012 at 12:16 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
>> Use the same mechanism we use for printing the configure command
>> line to config-host.mak to print it to config.log. This fixes a
>> bug where the config.log version didn't quote arguments with spaces.
>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>> If I'd noticed when I was adding the banner to config.log that we already
>> printed this in config-host.mak I'd have done it this way to start with...
>>
>>  configure |    4 +++-
>>  1 files changed, 3 insertions(+), 1 deletions(-)
>>
>> diff --git a/configure b/configure
>> index a5eb832..1b63436 100755
>> --- a/configure
>> +++ b/configure
>> @@ -22,7 +22,9 @@ rm -f config.log
>>
>>  # Print a helpful header at the top of config.log
>>  echo "# QEMU configure log $(date)" >> config.log
>> -echo "# produced by $0 $*" >> config.log

This left a trailing newline,

>> +printf "# Configured with:" >> config.log
>> +printf " '%s'" "$0" "$@" >> config.log

but this does not.  You probably want to add another echo afterwards, so
that the next line of the log doesn't look like another configure argument.

-- 
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: 620 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH] configure: Quote the configure args printed in config.log
  2012-03-07 17:06   ` Eric Blake
@ 2012-03-07 17:08     ` Peter Maydell
  2012-03-07 17:17       ` Eric Blake
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Maydell @ 2012-03-07 17:08 UTC (permalink / raw)
  To: Eric Blake; +Cc: qemu-trivial, Stefan Hajnoczi, qemu-devel

On 7 March 2012 17:06, Eric Blake <eblake@redhat.com> wrote:
>>>  # Print a helpful header at the top of config.log
>>>  echo "# QEMU configure log $(date)" >> config.log
>>> -echo "# produced by $0 $*" >> config.log
>
> This left a trailing newline,
>
>>> +printf "# Configured with:" >> config.log
>>> +printf " '%s'" "$0" "$@" >> config.log
>
> but this does not.  You probably want to add another echo afterwards, so
> that the next line of the log doesn't look like another configure argument.

If you look at the whole change, rather than just the
fragment Stefan quoted to comment on:

 # Print a helpful header at the top of config.log
 echo "# QEMU configure log $(date)" >> config.log
-echo "# produced by $0 $*" >> config.log
+printf "# Configured with:" >> config.log
+printf " '%s'" "$0" "$@" >> config.log
+echo >> config.log
 echo "#" >> config.log

...you'll see that it does exactly what you suggest.

-- PMM

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH] configure: Quote the configure args printed in config.log
  2012-03-07 12:40 ` Stefan Hajnoczi
  2012-03-07 17:06   ` Eric Blake
@ 2012-03-07 17:09   ` Peter Maydell
  1 sibling, 0 replies; 8+ messages in thread
From: Peter Maydell @ 2012-03-07 17:09 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: qemu-trivial, qemu-devel

On 7 March 2012 12:40, Stefan Hajnoczi <stefanha@gmail.com> wrote:
>> +printf "# Configured with:" >> config.log
>> +printf " '%s'" "$0" "$@" >> config.log
>
> You use an interesting feature of printf(1)- it applies the (short)
> format string as long as there are arguments.  I checked that this is
> in the specification:
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html

Yes, I had to look up the spec to figure out why it worked too :-)

-- PMM

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH] configure: Quote the configure args printed in config.log
  2012-03-07 12:16 [Qemu-devel] [PATCH] configure: Quote the configure args printed in config.log Peter Maydell
  2012-03-07 12:40 ` Stefan Hajnoczi
@ 2012-03-07 17:14 ` Avi Kivity
  2012-03-07 17:21   ` Peter Maydell
  1 sibling, 1 reply; 8+ messages in thread
From: Avi Kivity @ 2012-03-07 17:14 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-trivial, qemu-devel

On 03/07/2012 02:16 PM, Peter Maydell wrote:
> Use the same mechanism we use for printing the configure command
> line to config-host.mak to print it to config.log. This fixes a
> bug where the config.log version didn't quote arguments with spaces.
>  
>  # Print a helpful header at the top of config.log
>  echo "# QEMU configure log $(date)" >> config.log
> -echo "# produced by $0 $*" >> config.log
> +printf "# Configured with:" >> config.log
> +printf " '%s'" "$0" "$@" >> config.log
> +echo >> config.log
>  echo "#" >> config.log
>  

This still breaks if an argument has a single quote.  bash's printf's %q
deals with this correctly, but not sure how portable it is.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH] configure: Quote the configure args printed in config.log
  2012-03-07 17:08     ` Peter Maydell
@ 2012-03-07 17:17       ` Eric Blake
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Blake @ 2012-03-07 17:17 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-trivial, Stefan Hajnoczi, qemu-devel

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

On 03/07/2012 10:08 AM, Peter Maydell wrote:
> If you look at the whole change, rather than just the
> fragment Stefan quoted to comment on:
> 
>  # Print a helpful header at the top of config.log
>  echo "# QEMU configure log $(date)" >> config.log
> -echo "# produced by $0 $*" >> config.log
> +printf "# Configured with:" >> config.log
> +printf " '%s'" "$0" "$@" >> config.log
> +echo >> config.log
>  echo "#" >> config.log
> 
> ...you'll see that it does exactly what you suggest.

Good to hear!  Serves me right for not paying attention to the thread
until my personal keyword of 'opengroup' appeared mid-stream, at which
point I'd already deleted your original message to see the full context.

-- 
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: 620 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH] configure: Quote the configure args printed in config.log
  2012-03-07 17:14 ` Avi Kivity
@ 2012-03-07 17:21   ` Peter Maydell
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Maydell @ 2012-03-07 17:21 UTC (permalink / raw)
  To: Avi Kivity; +Cc: qemu-trivial, qemu-devel

On 7 March 2012 17:14, Avi Kivity <avi@redhat.com> wrote:
> This still breaks if an argument has a single quote.  bash's printf's %q
> deals with this correctly, but not sure how portable it is.

True, but we've lived with it for the code that writes to config-host.mak
since 2008 (commit fd69fe2b)...

-- PMM

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-03-07 17:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-07 12:16 [Qemu-devel] [PATCH] configure: Quote the configure args printed in config.log Peter Maydell
2012-03-07 12:40 ` Stefan Hajnoczi
2012-03-07 17:06   ` Eric Blake
2012-03-07 17:08     ` Peter Maydell
2012-03-07 17:17       ` Eric Blake
2012-03-07 17:09   ` Peter Maydell
2012-03-07 17:14 ` Avi Kivity
2012-03-07 17:21   ` Peter Maydell

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).