Thank you for your investigation.
So the problem in function syntax is that you are using POSIX compliant mode of bash. In this mode bash doesn't support modern features of bash.
Try to add "set –o posix" line before "set -e" in the origin script. It should disable POSIX compliant mode in che script. I hope it will allow you to run unchanged script.
But now with changed syntax of functions you have another problem:
JAVA_HOME is not set. Please set to directory of JVM or JRE.
It is possible that parsing fails because of POSIX compliant mode of bash. Check if this error happens when you disable that mode. If it still present, please, ping me again.
BTW looks like we need improve script to disable POSIX compliant mode at the beginning of the script. Can you create an issue on github with description of your problem.
Also output is too messy and doesn't allow to identify error message easily. If you think so, please, create issue on github with example of output you've provided. It is a good example.