The problem is that bash throws an error if you try to access an element of an undeclared array using a +
. For example:
$ echo "${arr[D+]}"
-bash: D+: syntax error: operand expected (error token is "+")
$ echo "${arr[foo]}" # works
However, if you declare the array first, it works:
$ declare -A arr
$ echo ${arr[D+]} # works
So, you need to make sure that the arrays jgWS
, jgLOSS
and jgEXTRA
have been declared up front, before you access them in your if-statements.
For example, currently the jgWS
array is declared only if this condition is met: [ $W1_Judge != 0 -o $S1_Judge != 0 ]
. Later on, you try to use the array here: if [[ "${jgWS[${!DESC1}]}" == "WSNG" ]]
, but it might not have been initialised, in which case it fails.