[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: '${#@}' expands to an integer
From: |
Lawrence Velázquez |
Subject: |
Re: '${#@}' expands to an integer |
Date: |
Wed, 05 Jul 2023 21:18:52 -0400 |
User-agent: |
Cyrus-JMAP/3.9.0-alpha0-531-gfdfa13a06d-fm-20230703.001-gfdfa13a0 |
On Wed, Jul 5, 2023, at 9:01 PM, Wiley Young wrote:
> Here's some code as observed "in the wild:"
>
> `[[ ${#@} -ne 0 ]] && ...`
>
> Perhaps the parser is reading this as an incomplete parameter
> transformation? It seems from context that the original intent was simply...
>
> `[[ $# -ne 0 ]] && ...`
>
> As it happens, the effect appears to be the same either way, but unless I'm
> missing something, as syntax ${#@} appears to be undefined.
That syntax is defined and documented.
${#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