feature request: ${@ command; } and ${* command; } funsubs to expand to all elements of the local array REPLY
Zachary Santer <[email protected]> Thu, 2 Apr 2026 01:54:15 -0400
| Newsgroups | gmane.comp.shells.bash.bugs |
|---|---|
| Message-ID | <CABkLJU+V8qX8hnLz4U5_Oqvx0-3O8puTs9ZpFcL-foYf+P7Hbw@mail.gmail.com> |
$ printf '%s\n' "${| REPLY=( zero one two ); }"
zero
$ printf '%s\n' "${@ REPLY=( zero one two ); }"
zero
one
two
$ printf '%s\n' "${* REPLY=( zero one two ); }"
zero one two
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.
If REPLY is left unset, "${@ command; }" would expand to nothing,
rather than the empty string, when double-quoted.
When REPLY remains a scalar but is set, ${@ command; } and ${*
command; } would behave identically to ${| command; }.
Would allow, for instance:
$ foo=3
$ for x in "${@ eval "REPLY=( {0..${foo}} )"; }"; do
> printf '%s\n' "${x}"
> done
0
1
2
3
Admittedly, ${* command; } wouldn't give you anything you can't get
with ${| command; }.
printf '%s\n' \
"${|
local -a array=( zero one two )
REPLY="${array[*]}"
}"
zero one two
So the only real purpose in adding that would be congruence with
${@}/${*} and ${array[@]}/${array[*]}.
Zack