Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14505

Re: Assignment of associative arrays through braces

Path csiph.com!3.us.feeder.erje.net!feeder.erje.net!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From konsolebox <konsolebox@gmail.com>
Newsgroups gnu.bash.bug
Subject Re: Assignment of associative arrays through braces
Date Sun, 19 Aug 2018 22:27:31 +0800
Lines 41
Approved bug-bash@gnu.org
Message-ID <mailman.5284.1534688895.1292.bug-bash@gnu.org> (permalink)
References <CAJnmqwZ9nfYmodcGXQpZq4Z94bdybbfwF+SJSnv-CedK-F6fAg@mail.gmail.com> <e2235d5e-ac0b-81c1-3da1-615ee6b28c7c@case.edu> <CAJnmqwbPtWSq2xuLDmq-a0zQz=AaVrZ==QA9fv97dWThmDNiFQ@mail.gmail.com>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
X-Trace usenet.stanford.edu 1534688896 25342 208.118.235.17 (19 Aug 2018 14:28:16 GMT)
X-Complaints-To action@cs.stanford.edu
Cc bug-bash <bug-bash@gnu.org>
To Chester Ramey <chet.ramey@case.edu>
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=vFDR78am6Tnx3KELGFWOQkvByaTVWeAuh6JjGOGEOwE=; b=ey+6AmsJXCh6HmzLeapnr1qbeJXrL/XbQcCTUoqm+bZSrxtG67dcPsUatZMZ7EgvBs CUI6FnUb2Ki4XQOgbcTfaW3ZLpG4mRQrk7TDhr9kSr+OCU1yV3XLOIeXVbRbECp53Yy1 SUO3LPENuN/bf/s9AodqBbhBIvfQ8Z2dNkdY9jphpP7ILQinrQ9R0hgZ5OyggboyabF9 hfuuE3a286uKC/jK9Pr8jG4CzkUmbH7Ekb0Y8DlBgjSKWkSagEvbY7m/Lg6/hii+HgGA 9Iv5Xwmisr2RnDrsGfy4/097MUlaI5o31DxONgc8Czg+6BofdXipcRQiFA+cwgZV0vjF qcVw==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=vFDR78am6Tnx3KELGFWOQkvByaTVWeAuh6JjGOGEOwE=; b=NQXYyRJVeWyqZI0l+w43wgQWxD9WLwoEyGoQzL4ej71eZAOXqVnhjAo7FEA6JLan7n qMiBFS+DN1TjNVL6eTC0GmCj7D/pZV3aWe9KxrQr72OqBvyRkTbDpx5SS8ZUv7IqqRO+ W+g2l+orKNVpGbooORec9qq+mhU503+7GTjTC2pgxZRTE5w4pzYIRvzkVfDG0iSJCERZ cwZSq3POivTtOdYOFMFoLLCe9YT7mC5OaJL08ZbLn8l933maOUmcK6hcSUAVcuZU+Z2y EXxemsjiT6/fnfsUvCaVpeOG0/P0hSZkSMXdFr+5egQQJyQvA0yfN9k5AvJGmWS1ZEwC OjUg==
X-Gm-Message-State AOUpUlEIPsW3KWBAoUd2Gx8LD/NWxSbVXBkU8NLgxO0mV/EjAwYZ9P36 Zvf/hGvgEUjyksLSrUQ4DTUoRqM2Dzc26vS/H5Q=
X-Google-Smtp-Source AA+uWPyfaPnNofci5qVKXtMaPrmWYQxXhbTZKQdRR/zG+xZwRXeNTcuXiL8cSkbt0ET3RjgUMleW3gRWzdNXqxxmfIU=
X-Received by 2002:a24:7882:: with SMTP id p124-v6mr21156847itc.111.1534688892251; Sun, 19 Aug 2018 07:28:12 -0700 (PDT)
In-Reply-To <CAJnmqwbPtWSq2xuLDmq-a0zQz=AaVrZ==QA9fv97dWThmDNiFQ@mail.gmail.com>
X-detected-operating-system by eggs.gnu.org: Genre and OS details not recognized.
X-Received-From 2607:f8b0:4001:c0b::236
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash/>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:14505

Show key headers only | View raw


On Wed, Aug 1, 2018 at 12:53 AM, konsolebox <konsolebox@gmail.com> wrote:
> On Tue, Jul 31, 2018 at 10:31 PM, Chet Ramey <chet.ramey@case.edu> wrote:
>> On 7/27/18 7:13 PM, konsolebox wrote:
>>> Hi Chet,
>>>
>>> I wonder if you can allow bash to have another syntax to allow simpler
>>> declaration and/or definition of associative arrays.  The changes
>>> needed to have it done seem simple enough, and the only conflict it
>>> makes is a scalar `var={...` assignment, which in my opinion is better
>>> quoted to make it more readable and less questionable from other
>>> syntaxes like brace expansion.  I believe most people intuitively
>>> quotes it, and assignments that start with `{` is fairly rare.
>>
>> So it's syntactic sugar for `declare -gA a; a=( ... )'?
>
> That surely is one of the main goals, but it's not exact.  `declare
> -gA a; a=(...)` would always affect the main global scope.
>
> Example:
>
> $ g() { declare -gA a=([x]=y); }; f() { local -A a=(); g; declare -p
> a; }; declare -A a=([a]=b); f; declare -p a
> declare -A a=()
> declare -A a=([x]="y" )
>
> But as shown in my earlier example, a={...} would only affect the
> nearest scope which was local a={}.
>
> This proposal simply requests an intuitively equivalent simple
> assignment syntax for associative arrays just like a='...' and
> a=(...), with same behavior for scoping.
>
> Maybe we can add another option like -G to have similar effect but
> that's a little different already.  Just allowing a={} would make it
> simpler for every scripter.

By the way, is this rejected?

-- 
konsolebox

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: Assignment of associative arrays through braces konsolebox <konsolebox@gmail.com> - 2018-08-19 22:27 +0800

csiph-web