I'm trying to learn bash. In some tutorial, I found select loop. But it doesn't work on either my MAC OS or Linux. My code is like this:
#!/bin/bash
names="Kyle Cartman Stan Quit"
PS3="Select character: "
select name in $names
do
echo "name="$name
done
I use ./test.sh to call this program and the result it like this:
1) Kyle
2) Cartman
3) Stan
4) Quit
Select character: Kyle
name=
Select character: Stan
name=
Select character:
It seems that it can not detect my input. Could anyone help me?