[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
'${#@}' expands to an integer
From: |
Wiley Young |
Subject: |
'${#@}' expands to an integer |
Date: |
Wed, 5 Jul 2023 18:01:46 -0700 |
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. Possibly not a
bug, therefore?
$ set -- a b c d
$ echo "$#"
4
$ echo "$@"
a b c d
$ echo "$#@"
4@
$ echo ${#@}
4
,0 , ,0@ ,0 ,'0'
$ echo ,$# ,$@ ,$#@ ,${#@} ,${#@Q} ,"${#@}"
+ echo ,0 , ,0@ ,0 ','\''0'\''' ,0
,0 , ,0@ ,0 ,'0' ,0
$ set --
+ set --
$ echo $#
+ echo 0
0
$ [[ ${#@} -ne 0 ]]; echo $?
+ [[ 0 -ne 0 ]]
+ echo 1
1
$ [[ ${#} -ne 0 ]]; echo $?
+ [[ 0 -ne 0 ]]
+ echo 1
1
Wiley
- '${#@}' expands to an integer,
Wiley Young <=