configure: Quote the configure args printed in config.log
PATCH 1/1 configure: Quote the configure args printed in config.log
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.
---
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(-)
configure +3 -1
@@ -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() {
Signature · 1 line
1.7.1
Stefan Hajnoczi
AppliedQuoted 20 lines · Peter Maydell
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 <[email protected]>---
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(-)configure +0
-0@@ -22,7 +22,9 @@ rm -f config.log # Print a helpful header at the top of config.logecho "# QEMU configure log $(date)" >> config.log
configure rm -f config.log · line 26
Quoted 3 lines
configure +2
-1-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
Quoted 19 lines · Stefan Hajnoczi
Quoted 18 lines · Peter Maydell
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 <[email protected]>---
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(-)configure +0
-0@@ -22,7 +22,9 @@ rm -f config.log
Quoted 3 lines
configure rm -f config.log · line 25
Quoted 3 lines
configure +0
-1# 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,
Quoted 2 lines
configure rm -f config.log · line 26
Quoted 2 lines
configure +2
-0+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.
Signature · 2 lines
Eric Blake [email protected] +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 11 lines · Eric Blake
Quoted 3 lines
Quoted 3 lines
# 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,
Quoted 2 lines
configure rm -f config.log · line 26
Quoted 2 lines
configure +2
-0+printf "# Configured with:" >> config.log +printf " '%s'" "$0" "$@" >> config.logbut 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
Quoted 11 lines · Peter Maydell
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
configure +3
-1-echo "# produced by $0 $*" >> config.log +printf "# Configured with:" >> config.log +printf " '%s'" "$0" "$@" >> config.log +echo >> config.log echo "#" >> config.log
Quoted 1 line
...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.
Signature · 2 lines
Eric Blake [email protected] +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 7 lines · Stefan Hajnoczi
configure rm -f config.log · line 26
Quoted 2 lines
configure +2
-0+printf "# Configured with:" >> config.log +printf " '%s'" "$0" "$@" >> config.logYou 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
configure rm -f config.log · line 28
Quoted 12 lines · Peter Maydell
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
configure +3
-1-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.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 2 lines · Avi Kivity
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