Le 21/08/2021 à 00:59, Greg Wooledge écrivait :
The fact that "${a[@]@K}" expands to a single word is surprising to me.
I know someone else already mentioned it in this thread (sorry, I forgot
who it was), but it would be nice if there were a similar one that gave
a list of multiple words.
unico
The fact that "${a[@]@K}" expands to a single word is surprising to me.
I know someone else already mentioned it in this thread (sorry, I forgot
who it was), but it would be nice if there were a similar one that gave
a list of multiple words.
unicorn:~$ printf '<%s> ' "${a[@]@Q}"; echo
<'1'> <'2'>
On Fri, Aug 20, 2021, at 6:11 PM, Léa Gris wrote:
> Le 21/08/2021 à 00:06, Chet Ramey écrivait :
> > The best way to clone an associative array is:
> >
> > declare -A options
> > eval options=\( "${assoc[@]@K}" \)
> >
> > The quoting @K performs is eval-safe.
> >
>
> Although I was not attempti
Le 21/08/2021 à 00:06, Chet Ramey écrivait :
On 8/19/21 6:37 AM, Léa Gris wrote:
#!/usr/bin/env bash
declare -A assoc=(
[P]=piano
[TB]='foldable table'
['CH AIR']=chair
)
options=("${assoc[@]@K}")
The best way to clone an associative array is:
declare -A options
eval options=\( "${as
On 8/19/21 6:37 AM, Léa Gris wrote:
#!/usr/bin/env bash
declare -A assoc=(
[P]=piano
[TB]='foldable table'
['CH AIR']=chair
)
options=("${assoc[@]@K}")
The best way to clone an associative array is:
declare -A options
eval options=\( "${assoc[@]@K}" \)
The quoting @K performs is eval
2021年8月19日(木) 19:37 Léa Gris :
> Current implementation of @K is pretty-much useless for the dialog use-case:
>
> > #!/usr/bin/env bash
> >
> > declare -A assoc=(
> > [P]=piano
> > [TB]='foldable table'
> > ['CH AIR']=chair
> > )
> >
> > options=("${assoc[@]@K}")
I this particular case, you
Le 19/08/2021 à 12:09, Koichi Murase écrivait :
$ printf '<%s>\n' "${A[@]@A}"
<-A>
The problem of ${A[@]@A} is that it is not so useful when one wants to
define a clone associative array with a different name but with the
same contents as A. Instead, using ${A[@]@K}, one could do
$ declare -
2021年8月19日(木) 18:16 Ilkka Virta :
> On Thu, Aug 19, 2021 at 5:49 AM Koichi Murase wrote:
>> FYI, zsh provides this feature for associative arrays with the syntax
>> ${(kv)assoc} or ${(@kv)assoc}. Note that Bash-5.1 already has a
>> similar feature ${array[@]@K}, but the substitution result is quot