dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] dash uses $* instead of $@ in variable assignments
@ 2015-11-26 19:44 Gioele Barabucci
  2015-11-26 21:07 ` Harald van Dijk
  2015-11-26 21:37 ` Stephane Chazelas
  0 siblings, 2 replies; 4+ messages in thread
From: Gioele Barabucci @ 2015-11-26 19:44 UTC (permalink / raw)
  To: dash

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 c

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 <gioele@svario.it>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] dash uses $* instead of $@ in variable assignments
  2015-11-26 19:44 [BUG] dash uses $* instead of $@ in variable assignments Gioele Barabucci
@ 2015-11-26 21:07 ` Harald van Dijk
  2015-11-26 21:37 ` Stephane Chazelas
  1 sibling, 0 replies; 4+ messages in thread
From: Harald van Dijk @ 2015-11-26 21:07 UTC (permalink / raw)
  To: Gioele Barabucci; +Cc: dash

On 26/11/2015 20:44, Gioele Barabucci wrote:
> 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 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

> 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 <gioele@svario.it>
>
> --
> To unsubscribe from this list: send the line "unsubscribe dash" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] dash uses $* instead of $@ in variable assignments
  2015-11-26 19:44 [BUG] dash uses $* instead of $@ in variable assignments Gioele Barabucci
  2015-11-26 21:07 ` Harald van Dijk
@ 2015-11-26 21:37 ` Stephane Chazelas
  2015-12-02 22:10   ` Gioele Barabucci
  1 sibling, 1 reply; 4+ messages in thread
From: Stephane Chazelas @ 2015-11-26 21:37 UTC (permalink / raw)
  To: dash

2015-11-26 20:44:26 +0100, 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:
> 
>     $ 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).

-- 
Stephane


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] dash uses $* instead of $@ in variable assignments
  2015-11-26 21:37 ` Stephane Chazelas
@ 2015-12-02 22:10   ` Gioele Barabucci
  0 siblings, 0 replies; 4+ messages in thread
From: Gioele Barabucci @ 2015-12-02 22:10 UTC (permalink / raw)
  To: dash

On 26/11/2015 22:37, Stephane Chazelas wrote:
> 2015-11-26 20:44:26 +0100, 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:
>>
>>     $ 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 <gioele@svario.it>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-12-02 22:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-26 19:44 [BUG] dash uses $* instead of $@ in variable assignments Gioele Barabucci
2015-11-26 21:07 ` Harald van Dijk
2015-11-26 21:37 ` Stephane Chazelas
2015-12-02 22:10   ` Gioele Barabucci

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).