dash uses $* instead of $@ in variable assignments
Hello,
I am forwarding a bug [1] reported by a Debian user: dash incorrectly uses $* instead of the requested $@ inside variable assignments. The current version of dash is affected by this bug.
A simple test from the original reporter:
$ dash -c 'IFS=:$IFS ; set -- a b c ; echo "$@" ; x="$@" ; echo "$x"'
a b c
a:b:c $ bash --posix -c 'IFS=:$IFS ; set -- a b c ; echo "$@" ; x="$@" ;
echo "$x"'
a b c
a b cThis error is reproducible with dash 0.5.7 and with the current master git master branch, commit 2e5842258bd5b252ffdaa630db09c9a19a9717ca.
[1] https://bugs.debian.org/764365
--
Gioele Barabucci <[email protected]>
Quoted 8 lines · Gioele Barabucci
Hello,
I am forwarding a bug [1] reported by a Debian user: dash incorrectly uses
$*instead of the requested$@inside variable assignments. The current version of dash is affected by this bug.A simple test from the original reporter:
Quoted 8 lines
$ dash -c 'IFS=:$IFS ; set -- a b c ; echo "$@" ; x="$@" ; echo "$x"' a b c a:b:c$ bash --posix -c 'IFS=:$IFS ; set -- a b c ; echo "$@" ; x="$@" ; echo "$x"' a b c a b c
The behaviour for "$@" is underspecified except for very specific situations. Both behaviours are very defensible. There is an attempt to clear up the requirements for the future, but even with the cleared up wording, the behaviour of var=$@ and var="$@" would remain unspecified. See <http://austingroupbugs.net/view.php?id=888> for details.
Cheers,
Harald van Dijk
Quoted 12 lines
This error is reproducible with dash 0.5.7 and with the current master git master branch, commit
2e5842258bd5b252ffdaa630db09c9a19a9717ca.[1] https://bugs.debian.org/764365
--
Gioele Barabucci <[email protected]>--
To unsubscribe from this list: send the line "unsubscribe dash" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
2015-11-26 20:44:26 +0100, Gioele Barabucci:
Quoted 11 lines
Hello,
I am forwarding a bug [1] reported by a Debian user: dash incorrectly uses
$*instead of the requested$@inside variable assignments. The current version of dash is affected by this bug.A simple test from the original reporter:
$ dash -c 'IFS=:$IFS ; set -- a b c ; echo "$@" ; x="$@" ; echo "$x"' a b c a:b:c
[...]
This behaviour is what I expect and is common to other shells as well.
$* and $@ are the concatenation of the positional parameters with the first character of $IFS, but "$@" in list contexts expands to all the position parameters as separate words. That's a logical continuation to the Bourne behaviour (which concatenated on space instead of the first character of $IFS).
POSIX used to be unclear about it. I had raised the issue some time ago and I beleive there's a new wording. See the longish discussion at
http://thread.gmane.org/gmane.comp.standards.posix.austin.general/9972
In any case, you should only use $@ quoted and in list contexts. $* may be used quoted in non-list contexts.
IIRC the proposed new wording for the POSIX spec would make this behaviour of dash non-conformant:
$ dash -c 'set a b c; IFS=; echo $*' abc
(even though I'd argue it's a logical design choice).
Signature · 1 line
Stephane
Quoted 9 lines · Stephane Chazelas
2015-11-26 20:44:26 +0100, Gioele Barabucci:Quoted 8 lines
Hello,
I am forwarding a bug [1] reported by a Debian user: dash incorrectly uses
$*instead of the requested$@inside variable assignments. The current version of dash is affected by this bug.A simple test from the original reporter:
Quoted 7 lines
Quoted 3 lines
$ dash -c 'IFS=:$IFS ; set -- a b c ; echo "$@" ; x="$@" ; echo "$x"' a b c a:b:c[...]
This behaviour is what I expect and is common to other shells as well.
Hi,
so from the answers I got this looks like an intended behaviour. Fair enough. :) For the sake of triage I will then mark the Debian bug as wontfix.
Regards,
--
Gioele Barabucci <[email protected]>