From: Stephane Chazelas <stephane.chazelas@gmail.com>
To: dash@vger.kernel.org
Subject: Re: [BUG] dash uses $* instead of $@ in variable assignments
Date: Thu, 26 Nov 2015 21:37:53 +0000 [thread overview]
Message-ID: <20151126213753.GA8662@chaz.gmail.com> (raw)
In-Reply-To: <n37neq$eem$1@ger.gmane.org>
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
next prev parent reply other threads:[~2015-11-26 21:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2015-12-02 22:10 ` Gioele Barabucci
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151126213753.GA8662@chaz.gmail.com \
--to=stephane.chazelas@gmail.com \
--cc=dash@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.