From: Simon Wistow Date: 17:42 on 19 Jul 2006 Subject: tcsh's conditionals Oh tcsh - so much to despise about you my little hate dumpling stuffed with loathsomeness. How we could while away the evenings talking about your little pecadillos. I can picture it now - you'd be on the floor cowering and I'd be standing over you, repeatedly hitting you using a bat with a rusty nail through it, cackling whilst your screams for forgiveness became slowly muffled by your own sobbing. Good times. Good times. 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 ... if ($foo) then echo "foo" elsif ($bar) then echo "bar" endif or if ($foo) then echo "foo" else if ($bar) then echo "bar" endif Hmm. The second choice you say? My, my, my. That *is* interesting because, you see, the first choice doesn't provoke a compile error. No, no, no such niceties are for weak minded, lily livered, frankly pinko, leftie WIMP programmers. So gauche. So ... recherche. A real man's language would compile the first syntax fine and then ... oh, do excuse me, I'm chuckling just thinking about it ... and then silently ignore it. Unless of course there's a 'else' statement which will, in that case, *always* get run. Since it's the default case it will probably go undetected for YEARS until some poor schmoe is asked to find why a certain option isn't working on some script left lying around. Oh how he'll clutch his sides with mirth, wipe a tear of glee from his eyes and then sink back in his chair, plotty gruesome revenge on you. Tssk, I ramble. So indulgent of me to take up your precious time when it could be more productively spent making someone else's life a misery. Accept my apologies, please. Until we meet again, dear tcsh. I'm sure you'll recognise me - I'll be the one skull fucking you to death with the severed arms of your creators. I may be covered in blood and crying bloody murder. Yours, Simon
From: peter (Peter da Silva) Date: 19:09 on 19 Jul 2006 Subject: Re: tcsh's conditionals > 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 10:27 on 16 Apr 2008 by mariachi