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

[SOLVED] Libtool/zsh quoting problem: a zsh... bug?



    Hi all

 * David <david@xxxxxxxxxxxx> dixit:
> A example, with the littlecms source (http://www.littlecms.com):
[irrelevant lines stripped...]
> [huma@fargo] [~/lcms-1.15] % make
> ../libtool --tag=CC --mode=compile gcc -DPACKAGE_STRING=\"lcms\ 1.15\"
[...]
>  gcc -DPACKAGE_STRING=\"lcms 1.15\" [...]
[...]
>  gcc: 1.15": No such file or directory
[...]
> Where -DPACKAGE_STRING=\"lcms 1.15\" in the gcc command should be quoted
> to avoid the error.

    The problem is that zsh does word splitting in this construct:

    ${1+"$@"}

    This is easy to reproduce with this shell script:

#! /bin/sh

printf -- "------\n"
for ddmyvar
do
    printf -- "\t%s\n" "$ddmyvar"
done
printf -- "ARG is %s\n" "$arg"
printf -- "------\n"

# This is more or less what libtool does.
set variable "datum" ${1+"$@"}

printf -- "------\n"
for ddmyvar
do
    printf -- "\t%s\n" "$ddmyvar"
done
printf -- "ARG is %s\n" "$arg"
printf -- "------\n"

exit 0

    Invoked like this:

    $./test.sh Abroken\ string anotherarg
    ------
	    Abroken string
    	anotherarg
    ARG is 
    ------
    ------
	    variable
    	datum
	    Abroken
    	string
	    anotherarg
    ARG is 
    ------


    I don't know if this can be considered a zsh bug or not. The SUS
standard says that field splitting is done after parameter expansion,
so I think it should be done on the above expansion. Unfortunately,
Bash doesn't seem to do it.

    Anyway, the above construct doesn't look useful to me. I mean, if
$1 is set, we substitute all available arguments. If it is unset, we
don't substitune anything. So, this is equivalent to just
substituting "$@", and zsh doesn't perform word splitting on that...

    I'm thinking about submitting a patch to the libtool people, with
something like this:

    alias -g '${1+"$@"}'='"$@"'

    I know, that's a dirty hack, but I cannot think about any other
fix (except "fixing" zsh itself, although I'm not sure this is a
bug).

    Any suggestion???

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to... RAmen!



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