diff mbox

[1/5] configure: remove duplicate single quotes on config.log header

Message ID 20170727120210.6943-2-crosa@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Cleber Rosa July 27, 2017, 12:02 p.m. UTC
The generation of the informational header on config.log contains two
pairs of single quotes, which seems unintentional, and looks like
this:

  # QEMU configure log Thu Jul 26 08:17:15 EDT 2017
  # Configured with: './configure' '--target-list=x86_64-softmmu'

With this change, the quotes comprehend the entire command line:

  # QEMU configure log Mon Jul 26 08:17:35 EDT 2017
  # Configured with: './configure --target-list=x86_64-softmmu'

Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
 configure | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Peter Maydell July 27, 2017, 12:15 p.m. UTC | #1
On 27 July 2017 at 13:02, Cleber Rosa <crosa@redhat.com> wrote:
> The generation of the informational header on config.log contains two
> pairs of single quotes, which seems unintentional, and looks like
> this:
>
>   # QEMU configure log Thu Jul 26 08:17:15 EDT 2017
>   # Configured with: './configure' '--target-list=x86_64-softmmu'

I think this is deliberate. The idea is that the string is a
validly shell-quoted string that you can cut and paste
into a shell prompt if you want to. (This is less important
than it used to be now we have config.status.)

If your configure command has more than one line you get
something like this:

# Configured with: '../../configure'
'--target-list=arm-softmmu,aarch64-softmmu,arm-linux-user,aarch64-linux-user'
'--enable-debug' '--cc=ccache gcc' '--audio-drv-list=pa'

...and note in particular how the '--cc=ccache gcc' argument
is printed. Your change would give

# Configured with: '../../configure
--target-list=arm-softmmu,aarch64-softmmu,arm-linux-user,aarch64-linux-user
--enable-debug --cc=ccache gcc --audio-drv-list=pa'

which can't be cut and pasted, and is ambiguous.

thanks
-- PMM
Eric Blake July 27, 2017, 12:24 p.m. UTC | #2
On 07/27/2017 07:15 AM, Peter Maydell wrote:
> On 27 July 2017 at 13:02, Cleber Rosa <crosa@redhat.com> wrote:
>> The generation of the informational header on config.log contains two
>> pairs of single quotes, which seems unintentional, and looks like
>> this:
>>
>>   # QEMU configure log Thu Jul 26 08:17:15 EDT 2017
>>   # Configured with: './configure' '--target-list=x86_64-softmmu'
> 
> I think this is deliberate. The idea is that the string is a
> validly shell-quoted string that you can cut and paste
> into a shell prompt if you want to.

It IS deliberate.  If you want, you could improve the code to only emit
'' around arguments that require it rather than all arguments, but that
requires more shell code (it's easier to quote everywhere, even when it
looks strange because the quotes weren't necessary).

> ...and note in particular how the '--cc=ccache gcc' argument
> is printed.

Yes, that's a case where the quotes are necessary.
Cleber Rosa July 27, 2017, 1:47 p.m. UTC | #3
On 07/27/2017 08:24 AM, Eric Blake wrote:
> On 07/27/2017 07:15 AM, Peter Maydell wrote:
>> On 27 July 2017 at 13:02, Cleber Rosa <crosa@redhat.com> wrote:
>>> The generation of the informational header on config.log contains two
>>> pairs of single quotes, which seems unintentional, and looks like
>>> this:
>>>
>>>   # QEMU configure log Thu Jul 26 08:17:15 EDT 2017
>>>   # Configured with: './configure' '--target-list=x86_64-softmmu'
>>
>> I think this is deliberate. The idea is that the string is a
>> validly shell-quoted string that you can cut and paste
>> into a shell prompt if you want to.
> 
> It IS deliberate.  If you want, you could improve the code to only emit
> '' around arguments that require it rather than all arguments, but that
> requires more shell code (it's easier to quote everywhere, even when it
> looks strange because the quotes weren't necessary).
> 
>> ...and note in particular how the '--cc=ccache gcc' argument
>> is printed.
> 
> Yes, that's a case where the quotes are necessary.
> 

Right, now I can see why.  Thanks for the review!
diff mbox

Patch

diff --git a/configure b/configure
index 987f59b..344d6d2 100755
--- a/configure
+++ b/configure
@@ -35,9 +35,7 @@  rm -f config.log
 
 # Print a helpful header at the top of config.log
 echo "# QEMU configure log $(date)" >> config.log
-printf "# Configured with:" >> config.log
-printf " '%s'" "$0" "$@" >> config.log
-echo >> config.log
+echo "# Configured with: '$0 $@'" >> config.log
 echo "#" >> config.log
 
 print_error() {