[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Problems caused by ${1+"$@"}
From: |
Rob Leslie |
Subject: |
Problems caused by ${1+"$@"} |
Date: |
Wed, 5 Jun 2002 00:25:53 -0700 |
Hello,
In several places, autoconf uses the shell idiom ${1+"$@"} to substitute
the current positional parameters, if any. Unfortunately this is not
completely portable; in particular, when Zsh is invoked as /bin/sh, word
splitting is performed on the expanded parameters, so for example:
'CPP=cc -E -traditional-cpp'
as one parameter becomes three:
'CPP=cc' '-E' '-traditional-cpp'
This creates problems during argument parsing:
% ./configure CPP='cc -E -traditional-cpp'
configure: error: unrecognized option: -E
Try `./configure --help' for more information.
Even when such variables are passed through the environment, one may still
later encounter problems:
% make
/bin/sh ./config.status --recheck
running /bin/sh ./configure CPP=cc -E -traditional-cpp --no-create
--no-recursion
configure: error: unrecognized option: -E
Try `./configure --help' for more information.
make: *** [config.status] Error 1
I can suggest two possible solutions. One would be to use "$@" in place of
${1+"$@"}, unless there was a special reason for the latter expression. (I
don't have access to a lot of esoteric shells, but the Bourne-compatible
ones I've tested, at least, remove the "$@" if there are no positional
parameters.) Another possibility is to ensure Zsh is invoked as zsh rather
than sh, or alternatively, execute 'unsetopt SH_WORD_SPLIT'. This may,
however, break compatibility elsewhere if autoconf generally expects word
splitting to be performed on unquoted $parameter expansions.
This is an important issue because under Mac OS X, /bin/sh is Zsh.
Thanks,
--
Rob Leslie
address@hidden
- Problems caused by ${1+"$@"},
Rob Leslie <=