The if-else command in csh

I am not a great fan of tcsh or csh, but for some reason the server in my Uni uses CSH as the default shell and there are tool flows that have been designed assuming csh, so I do not want to change my shell and have to redo all the tools flows.

While tinkering around, I noticed a funny (for me) behaviour of the ‘if-else’ structure in csh

if_else1

In the above screen-shot one can see, that A has been defined equals 3. If I now write an if condition which evaluates to false, then I see the prompt on the next line change to an

 if?

However if I change the if condition so that it evaluates to true, then I do not see the if?. This means that whatever one types now will be executed. This is a good optimization on the part of the C Shell. However it can be confusing for a first time user. One would expect the shell to respond with a prompt that looks like a ‘command continuation’ and not a prompt that looks like a regular shell prompt.

 

Advertisements
The if-else command in csh