Bug#518752: update-exim4.conf: line 38: $@: unbound variable
On 2009-03-08 jidanni@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'
--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
03-10-2009, 05:56 PM
Andreas Metzler
Bug#518752: update-exim4.conf: line 38: $@: unbound variable
clone 518752 -1
reassign -1 bash
found -1 4.0-1
retitle -1 set -u should not error on "${@:+}" if there are no args
thanks
On 2009-03-08 Alban browaeys <prahal@yahoo.com> wrote:
> >From amethyst on freenode #bash (Neil Moore) :
> <amethyst> it is a bug I think
> <amethyst> that you still get the error even with ${@-foo}
> <amethyst> but ${@+"$@"} probably shouldn't error out
> <amethyst> since ${foo+bar} does not
> <amethyst> or ${foo+"$foo"}
> I believe this should be cloned to bash (kept here too because the
> current $@ is to be fixed either way).
> Please tell me if you want me to do it. I ll refresh my memories of the
> bts and proceed.
Thanks for the heads-up. Cloning.
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'
--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
03-14-2009, 03:04 PM
Andreas Metzler
Bug#518752: update-exim4.conf: line 38: $@: unbound variable
On 2009-03-08 Alban browaeys <prahal@yahoo.com> wrote:
> >From amethyst on freenode #bash (Neil Moore) :
> <amethyst> it is a bug I think
> <amethyst> that you still get the error even with ${@-foo}
> <amethyst> but ${@+"$@"} probably shouldn't error out
> <amethyst> since ${foo+bar} does not
> <amethyst> or ${foo+"$foo"}
> I believe this should be cloned to bash (kept here too because the
> current $@ is to be fixed either way).
[...]
Hello,
I think I am going to drop set -u since I have got the feeling that
the decreased readability due the workarounds for $@ and $* outweighs
the benefit of set -u.
I still consider this upstream change a bad idea. There is a reason
why "$@" expands to nothing instead of an empty string if there are no
commandline args.
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'
--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org