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

Reply via email to