Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Fix testsuite errors due to shell quoted parameter expansion issue.



[trimming the cc a bit]

On 08/03/2010 03:21 PM, Mikael Magnusson wrote:
>> But it is _also_ a bug in zsh; adding zsh-workers accordingly.
>>
>> $ zsh -cvx 'f=" val" e=; echo "$e"$f'
>> +zsh:1> f=' val' e=''
>> +zsh:1> echo ' val'
>>  val
>>
>> Oops - zsh only passed one argument to echo, with a leading space,
>> instead of passing an empty argument and letting echo supply the space.
>>  ksh93, pdksh, and dash get it right (although dash doesn't use quotes
>> in -vx output, hence my use of n() to force things to tell; n() is
>> another way to expose the bash and zsh bugs).
> 
> zsh doesn't do word splitting by default, you can enable it with the = modifier:
> % zsh -fcvx 'f=" val" e=; echo "$e"$=f'
> +zsh:1> f=' val' e=''
> +zsh:1> echo '' val
>  val
> 
> does what you want

Thanks for the information.

> 
> Alternatively you can make zsh try to be closer to sh by setting
> argv[0] to sh when executing it, or running 'emulate sh' as the first
> command (and possibly other ways I don't know about):
> % zsh -fcvx 'emulate sh;f=" val" e=; echo "$e"$f'
> +zsh:1> emulate sh
> +zsh:1> f=' val' e=''
> +zsh:1> echo '' val
>  val

In the context of portable shell programming, and autoconf in
particular, we already _always_ force zsh into 'emulate sh' mode, so
that we don't trip up on non-POSIX incompatibilities like this behavior
of word splitting.  So it should not be a problem for autoconf, other
than to remind users that portable programming requires the use of
'emulate sh' in scripts that don't pick up autoconf's automatic shell
sanitization prelude.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature



Messages sorted by: Reverse Date, Date, Thread, Author