bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [minor] Space after last element on assoc print


From: Dan Douglas
Subject: Re: [minor] Space after last element on assoc print
Date: Thu, 20 Oct 2016 15:40:40 -0500

On Wed, Oct 19, 2016 at 11:47 PM, Quentin L'Hours
<address@hidden> wrote:
> Hi,
>
> Bash Version: 4.4
> Release Status: release
>
> Description:
>
> Useless space after last item of a declare -p on an assoc array (indexed
> arrays don't print it, and neither does ksh typeset on assoc arrays).
> It doesn't seem to have any consequence though.
>
> Repeat-By:
>
> $ declare -A capital[fr]=Paris
> $ declare -p capital
> declare -A capital=([fr]="Paris" )

You cannot assign an attribute to an individual element of any array. The
behaviour for indexed arrays is described in the manual:

"declare -a name[subscript] is also accepted; the subscript is ignored."

In the case of a previously declared associative array in the current
scope, one might argue that bash should throw an error instead. I think
what you're seeing is bash taking a "reasonable default" instead of
throwing an error in response to a nonsensical assignment.

Note that ksh93 is different in some respects because it allows "nested
variables".



reply via email to

[Prev in Thread] Current Thread [Next in Thread]