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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s