The commands you supply are executed with eval
so it’s probably one of them which is “messed up”.
You can set -x
and export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
to see firsthand which command causes the error (prepare to see lots of trace output).
But in your case, it’s pretty obvious that it’s your command line preceding the message: it has an unclosed if
block.