Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #15193 > unrolled thread
| Started by | Léa Gris <lea.gris@noiraude.net> |
|---|---|
| First post | 2019-07-19 03:38 +0200 |
| Last post | 2019-07-19 03:38 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to gnu.bash.bug
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Unexpected result of array assignment Léa Gris <lea.gris@noiraude.net> - 2019-07-19 03:38 +0200
| From | Léa Gris <lea.gris@noiraude.net> |
|---|---|
| Date | 2019-07-19 03:38 +0200 |
| Subject | Re: Unexpected result of array assignment |
| Message-ID | <mailman.1714.1563500355.2688.bug-bash@gnu.org> |
[Multipart message — attachments visible in raw view] — view raw
On 18/07/2019 14:12, Greg Wooledge wrote:
>
> On Thu, Jul 18, 2019 at 10:58:52AM +0200, Henning wrote:
>
> eval 'foo=(["key"]="'"${foo["key"]}"' value2")'
>
>
> If you just want to work around the bug, why not do it in the simplest
> way possible?
>
> foo["key"]+=" value2"
>
> Of course, you are right.
Can be done safely with storing the intermediate value.
declare -A foo
foo=(["key"]="value1")
declare -p foo
_v="${foo["key"]}"
declare -p _v
foo=(["key"]="${_v} value2")
declare -p foo
Still safer than eval for an extra intermediary assignment.
And allow you to insert the old value of ${foo=["key"]} anywhere
in-between. The += string concatenation would not work in this case.
--
Léa Gris
Back to top | Article view | gnu.bash.bug
csiph-web