In a for loop I am looking to find out: If Array1 length matches Array2 length then break the for loop.
Shellcheck throws an error (while the script runs fine)
if [[ "${!Array1[@]}" == "${!Array2[@]}" ]] ; then
break;
fi
^-- SC2199: Arrays implicitly concatenate in [[ ]]. Use a loop (or explicit * instead of @).
I'm still learning bash and my teacher said "Always verify with Shellcheck" and to "always place conditionals in double [[ ]]" and to "never use * for array length"
The error(s) are removed with the correction
if [ "${!Array1[*]}" == "${!Array2[*]}" ] ; then
break;
fi
I was wondering what is the best practice here?
"${!Array1[@]}"is wrong."${#array[@]}".