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

2024-03-24 Thread Zachary Santer
On Thu, Mar 21, 2024 at 4:08 PM Chet Ramey wrote: > > On 3/20/24 3:05 PM, Zachary Santer wrote: > > > it's more work > > than if there were three separate parameter transformations. one each > > to always generate a declare command; an assignment statement; and the > > right hand side of a compoun

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

2024-03-21 Thread Chet Ramey
On 3/20/24 4:30 PM, Zachary Santer wrote: The point I'm trying to make is that ${var@A} expanding to either a declare command, an assignment statement, or nothing, depending on potentially changing criteria, is unnecessarily cumbersome. In whatever circumstances where a bash programmer would act

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

2024-03-21 Thread Chet Ramey
On 3/20/24 3:05 PM, Zachary Santer wrote: That expansion will produce a declare command if the variable has any attributes, since it needs one to reproduce them. If the variable has a value, but no attributes, you'll get an assignment statement. If there are no attributes and no value, you get

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: ${var@A}; hypothetical, related parameter transformations

2024-03-19 Thread Zachary Santer
On Mon, Mar 18, 2024 at 6:26 PM Zachary Santer wrote: > > I guess, in bash 5.1+, it could pass > "${assoc[*]@K}" > and then the receiving end could > eval "assoc=( ${assoc_message} )" > if I wanted to avoid declaring the associative array anew. If I wanted to duplicate an indexed array, however,

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

2024-03-18 Thread Zachary Santer
On Mon, Mar 18, 2024 at 6:26 PM Zachary Santer wrote: > { > declare -p assoc > printf '\x00' > } >&"${fd}" > in bash 4.2, which I'm actually pretty happy with. Rather. No %s there.

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

2024-03-18 Thread Zachary Santer
Was "Re: nameref and referenced variable scope, setting other attributes" On Mon, Mar 18, 2024 at 4:20 PM Chet Ramey wrote: > > On 3/14/24 8:57 PM, Zachary Santer wrote: > > > > While we're kind of on the subject, I find it really odd that the > > ${var@A} parameter expansion will expand to eithe