You need to put spaces around the == operator. Otherwise the test expression is a single word, and all non-empty words test successfully.
In addition, if you wish to be portable, you should use =
instead of ==
. And it is always wise to double quote variable expansions because [
won't do that for you.
if [ "$ANSWER" = y ]; then
On the other hand, if you are using bash (or ksh or zsh) you could use the more forgiving [[
conditional expression:
if [[ $ANSWER = y ]]; then