🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.bugs.4bsd
Article #30

Re: csh problem involving nested ifs?

#30
From: David C Lawrence
Date: Mon, 10 Jul 1989 17:11
32 lines
1890 bytes
In <685@wuphys.UUCP> marty@wuphys.UUCP (Marty Olevitch) writes:
Marty> It appears that csh does not correctly handle nested if-then-else
Marty> statements. The following script illustrates the problem, which appears
Marty> in versions of csh on MORE/bsd (mt Xinu 4.3), SunOS 3.1, SunOS 4.0, and
Marty> Ultrix 2.0. Am I missing some bug in this script? If not, it looks like
Marty> a bug in csh (an equivalent sh program works fine).

Yes it's a bug, no it's not a bug.  It's one of those ambivalent
things.  If you know what it is, you adjust your style by one
character or so and life goes on correctly again.

Major hacking on the script follows ...
Marty> #! /bin/csh
[...]
Marty> if($v1 == 1) then
Marty> 	echo checkpoint 1
Marty> 	if($v2 == 1) then
[...]
Marty> 	if($v2 == 1) then
[...]

If you change the "if(" to "if (" in each of the nested conditionals
you should find that your problem has vanished.  The problem is that
whitespace becomes significant within the first if block, at least as
far as further nested if blocks are concerned.  The parser used within
the if block is not the same one which parsed out the top if.

Dave
--
 (setq mail '("tale@pawl.rpi.edu" "tale@itsgw.rpi.edu" "tale@rpitsmts.bitnet"))
        "Drinking coffee for instant relaxation?  That's like drinking
               alcohol for instant motor skills."  -- Marc Price
Technical Details
Message-ID: <TALE.89Jul10131139@imagine.pawl.rpi.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rpi!rpi.edu!tale
References: <685@wuphys.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rpi!rpi.edu!tale
From: tale@pawl.rpi.edu (David C Lawrence)
Newsgroups: comp.bugs.4bsd,comp.unix.wizards
Subject: Re: csh problem involving nested ifs?
Message-ID: <TALE.89Jul10131139@imagine.pawl.rpi.edu>
Date: 10 Jul 89 17:11:39 GMT
References: <685@wuphys.UUCP>
Sender: usenet@rpi.edu
Reply-To: tale@pawl.rpi.edu
Distribution: comp
Lines: 32
In-reply-to: marty@wuphys.UUCP's message of 10 Jul 89 16:02:05 GMT