Re: tcsh's conditionals

[prev] [thread] [next] [lurker] [Date index for 2006/07/19]

From: peter (Peter da Silva)
Subject: Re: tcsh's conditionals
Date: 19:09 on 19 Jul 2006
> But, such pleasurable evenings will have to wait because we need to have 
> a talk about your conditional statements, you and I. No, no, there's no 
> need to be modest. Don't be shy. I merely want to ask you which of these 
> is the correct syntax ...

The correct syntax for conditionals in (t)csh is this:

	sh -c 'if [ $foo ]; then echo "foo"; else echo "bar"; fi'

No, I'm not kidding. Writing scripts in tcsh is demented. Csh doesn't parse
its control structures, even at runtime. They're all aliases on steroids,
layered on top of something more like the V6 shell than the Bourne shell,
and semantically "if/else/endif" just turn command execution and some of the
parsing on and off while running through all the commands in between looking
for the matching ends...

However, this particular screwup is technically not tcsh's fault. "elsif" is
just another command, you wouldn't want tcsh to start complaining about
commands that might be mistaken for typos. But don't let that discourage
you from hate, (t)csh has more than earned it.

But direct a smidgen of that hate to the idiot who wrote that script in (t)csh
in the first place.

Generated at 20:01 on 19 Jul 2006 by mariachi 0.52