When sh. / xxx.sh is executed, syntax error: “unexpected” appears

It is correct for standard bash, but in order to speed up the boot up, Ubuntu uses dash instead of traditional bash
solution: cancel dash
1. Execution: sudo dpkg reconfigure dash
2. Option: select No

Read More: