[Top][All Lists]

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

Re: @K transformation

From: Chet Ramey
Subject: Re: @K transformation
Date: Fri, 20 Aug 2021 18:06:23 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.12.0

On 8/19/21 6:37 AM, Léa Gris wrote:

#!/usr/bin/env bash

declare -A assoc=(
  [TB]='foldable table'
  ['CH AIR']=chair


The best way to clone an associative array is:

declare -A options
eval options=\( "${assoc[@]@K}" \)

The quoting @K performs is eval-safe.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

reply via email to

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