On Mon, Mar 10, 2025, at 12:38 PM, Zachary Santer wrote:
> There are other weird, undocumented things that you could have the
> same conversation about. ${#@} is equivalent to ${#}
This is documented and not at all weird. $# came from Bourne, and
${#@} is a logical extension of ${#var} that happens to expand to
the same value.
#
($#) Expands to the number of positional parameters
in decimal.
https://www.gnu.org/software/bash/manual/html_node/Special-Parameters.html
${#parameter}
The length in characters of the expanded value of
_parameter_ is substituted. If _parameter_ is `*'
or `@', the value substituted is the number of
positional parameters.
https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html
--
vq