Bug#518752: update-exim4.conf: line 38: $@: unbound variable

Andreas Metzler ametzler at downhill.at.eu.org
Sun Mar 8 13:42:11 UTC 2009


On 2009-03-08 jidanni at jidanni.org wrote:
> Package: exim4-config
> Version: 4.69-9
> Severity: important
> File: /usr/sbin/update-exim4.conf

> starting with bash version 4.0-1:

> /var/log/boot:Sun Mar  8 19:13:03 2009: Starting
> MTA:/usr/sbin/update-exim4.conf: line 38: $@: unbound variable

> because "set -u" now applies to $@ too.

Oh dear.

Upstream changelog:
d.  Fixed a bug that caused expansions of $@ and $* to not exit the shell if
    the -u option was enabled and there were no posititional parameters.

Posh also behaves this way, dash doesn't.

i.e. this
-------------
#!/bin/sh
set -u
echo "$@"
exit 0
-------------
causes "@: parameter not set" and a non-zero exitcode.

Personally I do not think this as clear cut as upstream's changelog
says. set -u should cause a failure if you try to "expand a variable
that is not set". However afaict it is not clear that the absence of
positional parameters should cause the shell to "not set" $@. The
standard just says "If there are no positional parameters, the
expansion of '@' shall generate zero fields, even when '@' is
double-quoted." So there is special-casing, "$@" expands to nul, not
the empty string.

With posh replacing "$@" with "${@:+}" works as a workaround, however
bash even then throws the error. - Is this a bug in bash?

cu andreas
-- 
`What a good friend you are to him, Dr. Maturin. His other friends are
so grateful to you.'
`I sew his ears on from time to time, sure'





More information about the Pkg-exim4-maintainers mailing list