Simple VI script

Okay using vi editor regular vi not VIM or any other hybrid.

What I'm trying to do is make a simple script in the csh. By the way what's better csh or sh for scripting? It's been a while since I did vi scripting....Anyway here's the purpose of the script.

I want to be able to give the script a "yes" answer and a "no" answer.....The yes answer will exit out of the script, and the no answer will cause the program to loop with an echo of "Do you want to exit" reading the answer everytime to check for yes or no. My problem is that the program reads the answer but no matter what answer I give the script it exits out of the script after it finishes echoing what I told it to. I can't get it to do what I want and need a bit of help....Here's the script...I know super basic I feel dumb. Here it is:


 if [ "$answer" = "" ]; then read answer
 while answer=n; do echo "Do you want to exit"
 read answer
 if answer=y; then exit

try changing the while line to
while [ $answer = "no" ] || [ $answer = "n" ]; do echo "Do you want to exit"

This tests to see if $answer is no or n

I figured it out before reading your reply. DOH!

By chance would you know how to set it up so as to tell it to echo "Bad Option" when you choose any other letter except for "n" and "y"?

csh is good as an interactive shell, but is pretty poor as a scripting language. See <A HREF="">Csh Programming Considered Harmful</A> on
<A HREF="">ksh93</A> is (IMO) probably the best shell for scripting, since it was designed with this use in mind, thus allowing some powerful features that other shells lack. See the answer to question number 1 on <A HREF="">this page</A>.