[Tfug] csh/tcsh users

Jim Secan jim at nwra.com
Wed Nov 2 16:04:29 MST 2005


If there are any csh/tcsh gurus out there I'm having an ongoing battle with
nested if-then-else constructs.  These things have worked for years on
Solaris, and I'm getting tired of hacking work-arounds on Linux (FC3).

An example:

if($BUILD_G == NO)then
   echo 'STATUS:  G matrix already built'
   if(!(-e $gelFile))then
      rm $gelFile
      ln -s $GMdir/$gelFile $gelFile
   endif
   if(!(-e $refFile))then
      rm $refFile
      ln -s $GMdir/$refFile $refFile
   endif
   echo Linked to gel and ref files in $GMdir
endif

If BUILD_G is NO, it works fine.  Otherwise, rather than not executing
everything between the initial "if" and the final "endif" the shell jumps
to the first "endif" it encounters and starts from there.  In this case, it
starts in at the    
"if(!(-e $refFile))then" line and keeps going.  Sorry, but this is just wrong.

So, has the shell got a bug (which it's had for several years now) or
what's going on?

Jim

*---------------------*-------------------------------*
| Jim Secan           | Northwest Research Assoc, Inc |
| (jim at nwra.com)      | 2455 E. Speedway, Suite 204   |
| (520) 319-7773      | Tucson, Arizona 85719         |
|    Space Weather Info: http://www.nwra-az.com/      |
*---------------------*-------------------------------*


More information about the tfug mailing list