Home > Enterprise >  bash : Bad Substitution on array variable
bash : Bad Substitution on array variable

Time:11-23

Below is my extract of the failure part:

if [[ -n "${war_to_be_deployed-}" ]] ; then
    [[ "${#runtime_args[@]-}" == "${#expected_runtime_args[@]-}" ]]             || _fatal "Failed runtime_args"     
    for ((i=0 ; i<${#runtime_args[@]-} ;   i)); do

throws below error on bash GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu). What is it that I'm doing incorrect here ? thank you.

${#runtime_args[@]-}: bad substitution

CodePudding user response:

${#runtime_args[@]} is number of elements in the array. The trialing - is what triggers the error. Is this script generated? It looks like a syntax error to me.

  • Related