bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature request: ${@ command; } and ${* command; } funsubs to expand to


From: Zachary Santer
Subject: feature request: ${@ command; } and ${* command; } funsubs to expand to all elements of the local array REPLY
Date: Thu, 2 Apr 2026 01:54:15 -0400

$ 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]