home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!darwin.sura.net!haven.umd.edu!news.umbc.edu!umbc8.umbc.edu!engel
- From: engel@umbc8.umbc.edu (Mr. Joshua F. Engel)
- Newsgroups: comp.unix.questions
- Subject: Bug (?) in csh
- Date: 31 Dec 1992 01:59:43 GMT
- Organization: University of Maryland, Baltimore County Campus
- Lines: 47
- Distribution: world
- Message-ID: <1htk6fINN9hn@news.umbc.edu>
- NNTP-Posting-Host: umbc8.umbc.edu
-
- I run the following C shell program under SunOS 4.1:
-
- #!/bin/csh -f
-
- if(0) then
- if(1) then
- echo 1
- endif
- echo 2
- endif
-
- ------------
- The output of the program is
-
- 2
-
- That is incorrect; there should be no output because the program
- should not enter the inside of the first if statement. Between
- this and other experiments, I conclude that csh matches ifs
- not with the corresponding endif but rather with the first
- endif.
-
- If I change the program so that the first if succeeds, the output
- is as anticipated:
-
- 1
- 2
-
- Is the the appropriate behavior?
-
- Note: I know that I can get around the problem with:
-
- if(0)
- (
- if(1)
- (
- echo 1
- )
- echo 2
- )
-
- but that isn't the point.
- --
- Joshua Engel |\
- President, |/ urgatorio
- | roductions
-
-