I have the following code snippet:
Code:
#!/bin/bash
question ()
{
echo '(y for yes, n for no, any other key to cancel)'
read tmp
if [ $tmp = "y" ]; then
echo "you typed 'yes'"
elif [ $tmp = "n" ]; then
clear
elif [ $tmp = "c" ]; then
kill 0
else question
fi
}
question
If I run this script and instead of typing any 'normal' key press <enter> the I get an error message:
Code:
./test.sh: line 6: [: =: unary operator expected
./test.sh: line 8: [: =: unary operator expected
./test.sh: line 10: [: =: unary operator expected
How can I get the script to react to <enter> the same way as to any key (except of course 'y', 'n' and 'c')?