So I want to validate a response of a user in tcsh script and that's what I have so far set var1=temp    while($var1 != [yY] && $var1 != [Yy][Ee][Ss] && $var1 != [Nn] && $var1 != [Nn][Oo])            echo Do you want to create a backup directory ? :        set response=&<         if ($response == [yY] || $respose == [Yy][Ee][Ss]) then            mkdir backup            echo Backupd directory created \n        else if($response == [nN] || $response == [Nn][Oo]) then            echo No backup directory is created \n        else            echo Please enter a valid respose ! \n            var1=$response        endif     endI basically want the user to either input Y,y,Yes,N,n,No and of course I also allow for a combination of small case and upper case in yes and now.But when I run the script, it gives me an error saying [yY]: No match. So I am guessing something is wrong when comparing $var1 to [Yy]. Basically I am validating the user input.And cai reassign var1 like I did, var1=$response, or do I have to use set again >
Comparing a variable to upper and lower case letters
string;tcsh
You probably meant !~, does not match regular expression, rather than !=, is not equal to.For $var =~ regexp and $var !~ regexp, the pattern on the right should not be quoted. For == and !=, you may quote the part on the right (and in fact I'd encourage this).Since != expects a string, [yY] was not parsed as a regular expression. Rather, the shell expanded it to any file whose name is y or Y. And since you didn't have one, the shell complained.This sort of thing, by the way, is why I prefer not to write scripts in tcsh, even though I use it as my interactive shell.