Re: ${var@A}; hypothetical, related parameter transformations

2024-03-20 Thread Zachary Santer
On Wed, Mar 20, 2024 at 3:44 PM Greg Wooledge wrote: > > This seems rather theoretical to me. If the associative array has > nothing in it, does it really matter whether it's nonexistent, only > declared as a scope placeholder (I think that's a thing...), or fully > declared but empty? The secon

Re: ${var@A}; hypothetical, related parameter transformations

2024-03-20 Thread alex xmb sw ratchev
On Wed, Mar 20, 2024, 20:44 Greg Wooledge wrote: > On Wed, Mar 20, 2024 at 03:05:56PM -0400, Zachary Santer wrote: > > I want a declare command, no matter what ${var@A} gives me. I have to > > write a function for that: generate_declare_command (). That function > > can work a couple of reasonabl

Re: ${var@A}; hypothetical, related parameter transformations

2024-03-20 Thread Greg Wooledge
On Wed, Mar 20, 2024 at 03:05:56PM -0400, Zachary Santer wrote: > I want a declare command, no matter what ${var@A} gives me. I have to > write a function for that: generate_declare_command (). That function > can work a couple of reasonable ways: This seems rather theoretical to me. If the assoc

Re: ${var@A}; hypothetical, related parameter transformations

2024-03-20 Thread Zachary Santer
On Wed, Mar 20, 2024 at 11:27 AM Chet Ramey wrote: > > On 3/19/24 8:56 PM, Zachary Santer wrote: > > > So I can get a couple of the things I want by manipulating what I get out > > of ${var@A} with fairly straightforward parameter expansions. If I needed a > > declare command and wasn't sure if I

Re: ${var@A}; hypothetical, related parameter transformations

2024-03-20 Thread Chet Ramey
On 3/19/24 8:56 PM, Zachary Santer wrote: So I can get a couple of the things I want by manipulating what I get out of ${var@A} with fairly straightforward parameter expansions. If I needed a declare command and wasn't sure if I would get one, I haven't found a way to expand that to something

Re: "${assoc[@]@k}" doesn't get expanded to separate words within compound assignment syntax

2024-03-20 Thread Zachary Santer
On Wed, Mar 20, 2024 at 9:32 AM Lawrence Velázquez wrote: > > https://lists.gnu.org/archive/html/bug-bash/2019-07/msg00056.html Wherein he shows that Zsh can do this without eval: > declare -a array=( a 1 b 2 c 3 ) > declare -A hash=( ${array[@]} ) > declare -p hash > => typeset -A hash=( [a]=1

Re: "${assoc[@]@k}" doesn't get expanded to separate words within compound assignment syntax

2024-03-20 Thread Lawrence Velázquez
On Wed, Mar 20, 2024, at 7:11 AM, Zachary Santer wrote: > On Wed, Mar 20, 2024 at 12:29 AM Lawrence Velázquez wrote: >> >> This isn't specific to ${var[@]@k}. >> >> $ kv1='a 1 b 2 c 3' >> $ kv2=(a 1 b 2 c 3) >> $ declare -A aa1=($kv1) aa2=(${kv2[@]}) aa3=("${kv2[@]}") >>

Re: "${assoc[@]@k}" doesn't get expanded to separate words within compound assignment syntax

2024-03-20 Thread alex xmb sw ratchev
On Wed, Mar 20, 2024, 12:59 Greg Wooledge wrote: > On Wed, Mar 20, 2024 at 12:53:07PM +0100, alex xmb sw ratchev wrote: > > On Wed, Mar 20, 2024, 12:49 Greg Wooledge wrote: > > > > > On Wed, Mar 20, 2024 at 07:11:34AM -0400, Zachary Santer wrote: > > > > On Wed, Mar 20, 2024 at 12:29 AM Lawrence

Re: "${assoc[@]@k}" doesn't get expanded to separate words within compound assignment syntax

2024-03-20 Thread Léa Gris
Le 20/03/2024 à 12:59, Greg Wooledge écrivait : s to that , simply declare -p and run that back That will work in some cases, yes. The problem is that it locks you in to having the same array name and the same attributes (if any) as the original array had. It also runs "declare" which can cre

Re: "${assoc[@]@k}" doesn't get expanded to separate words within compound assignment syntax

2024-03-20 Thread Greg Wooledge
On Wed, Mar 20, 2024 at 12:53:07PM +0100, alex xmb sw ratchev wrote: > On Wed, Mar 20, 2024, 12:49 Greg Wooledge wrote: > > > On Wed, Mar 20, 2024 at 07:11:34AM -0400, Zachary Santer wrote: > > > On Wed, Mar 20, 2024 at 12:29 AM Lawrence Velázquez > > wrote: > > > > A couple of previous discussi

Re: "${assoc[@]@k}" doesn't get expanded to separate words within compound assignment syntax

2024-03-20 Thread alex xmb sw ratchev
On Wed, Mar 20, 2024, 12:49 Greg Wooledge wrote: > On Wed, Mar 20, 2024 at 07:11:34AM -0400, Zachary Santer wrote: > > On Wed, Mar 20, 2024 at 12:29 AM Lawrence Velázquez > wrote: > > > A couple of previous discussions: > > > - https://lists.gnu.org/archive/html/bug-bash/2020-12/msg00066.html

Re: "${assoc[@]@k}" doesn't get expanded to separate words within compound assignment syntax

2024-03-20 Thread Greg Wooledge
On Wed, Mar 20, 2024 at 07:11:34AM -0400, Zachary Santer wrote: > On Wed, Mar 20, 2024 at 12:29 AM Lawrence Velázquez wrote: > > A couple of previous discussions: > > - https://lists.gnu.org/archive/html/bug-bash/2020-12/msg00066.html > > - https://lists.gnu.org/archive/html/bug-bash/2023-06/m

Re: "${assoc[@]@k}" doesn't get expanded to separate words within compound assignment syntax

2024-03-20 Thread Zachary Santer
On Wed, Mar 20, 2024 at 12:29 AM Lawrence Velázquez wrote: > > This isn't specific to ${var[@]@k}. > > $ kv1='a 1 b 2 c 3' > $ kv2=(a 1 b 2 c 3) > $ declare -A aa1=($kv1) aa2=(${kv2[@]}) aa3=("${kv2[@]}") > $ declare -p aa1 aa2 aa3 > declare -A aa1=(["a 1 b