The error message suggests that you are in fact not executing the script using
Either make the script executable and add a proper
#!-line on the first line of the script, e.g.
Or, execute the script with
$ bash script.sh
You should treat
bash as implementing separate languages, and use the correct interpreter for the script you're writing. In this case, you're using
read with the
-u option. This is originally a
ksh extension to the standard
read specification, and it's also implemented in
zsh. Hence, you need to run the script with
How to know when to use
sh and when to use
bash or some other shell? It's simple, you learn the way
sh works and what other features other shells add.