On Thu, Apr 2, 2026 at 1:54 AM Zachary Santer <[email protected]> wrote:
>
> Like the ${| command; } form, REPLY within the funsub starts life as
> an initially-unset local variable, not an initially empty indexed
> array variable. That way, REPLY can become either an indexed or
> associative array within the funsub.
I'm having second thoughts about this bit.
declare -a array=(
"${[@]| this_function args...; }"
)
this_function has no way to set REPLY as an associative array. declare
-A makes it local to the function, which doesn't work for this.
declare -Ag makes it global, which also doesn't work for this.
So the user would have to do something like this:
declare -a array=(
"${[@]|
declare -A REPLY
this_function args...
}"
)
If you need to use an associative array, chances are you need to
maintain the keys as you pass it around.
So allowing ${[@]| command; } to work for either an indexed or an
associative array would still force the user to do something a little
awkward to get it to work for an associative array, and it probably
wouldn't be used very often with one.
REPLY being an initially empty array variable inside the funsub would be fine.
Zack