home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / unix / question / 15071 < prev    next >
Encoding:
Internet Message Format  |  1992-12-30  |  1.2 KB

  1. Path: sparky!uunet!spool.mu.edu!darwin.sura.net!haven.umd.edu!news.umbc.edu!umbc8.umbc.edu!engel
  2. From: engel@umbc8.umbc.edu (Mr. Joshua F. Engel)
  3. Newsgroups: comp.unix.questions
  4. Subject: Bug (?) in csh
  5. Date: 31 Dec 1992 01:59:43 GMT
  6. Organization: University of Maryland, Baltimore County Campus
  7. Lines: 47
  8. Distribution: world
  9. Message-ID: <1htk6fINN9hn@news.umbc.edu>
  10. NNTP-Posting-Host: umbc8.umbc.edu
  11.  
  12. I run the following C shell program under SunOS 4.1:
  13.  
  14. #!/bin/csh -f
  15.  
  16. if(0) then
  17.     if(1) then
  18.         echo 1
  19.     endif
  20.     echo 2
  21. endif
  22.  
  23. ------------
  24. The output of the program is
  25.  
  26. 2
  27.  
  28. That is incorrect; there should be no output because the program
  29. should not enter the inside of the first if statement.  Between
  30. this and other experiments, I conclude that csh matches ifs
  31. not with the corresponding endif but rather with the first
  32. endif.
  33.  
  34. If I change the program so that the first if succeeds, the output
  35. is as anticipated:
  36.  
  37. 1
  38. 2
  39.  
  40. Is the the appropriate behavior?  
  41.  
  42. Note: I know that I can get around the problem with:
  43.  
  44. if(0)
  45. (
  46.     if(1)
  47.     (
  48.         echo 1
  49.     )
  50.     echo 2
  51. )
  52.  
  53. but that isn't the point.
  54. -- 
  55.                         Joshua Engel    |\
  56.                         President,      |/ urgatorio
  57.                                         |  roductions
  58.  
  59.