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

  1. Xref: sparky comp.unix.questions:15074 comp.sys.apple2.gno:743
  2. Newsgroups: comp.unix.questions,comp.sys.apple2.gno
  3. Path: sparky!uunet!zaphod.mps.ohio-state.edu!usc!news.cerf.net!netlabs!lwall
  4. From: lwall@netlabs.com (Larry Wall)
  5. Subject: Re: The Revenge of CSH
  6. Message-ID: <1992Dec31.040054.4851@netlabs.com>
  7. Sender: news@netlabs.com
  8. Nntp-Posting-Host: scalpel.netlabs.com
  9. Organization: NetLabs, Inc.
  10. References: <Bzz748.GDK@csn.org>
  11. Date: Thu, 31 Dec 1992 04:00:54 GMT
  12. Lines: 218
  13.  
  14. In article <Bzz748.GDK@csn.org> bazyar@teal.csn.org (Jawaid Bazyar) writes:
  15. :   The reason for this reply is that I'm one of a number of folks working
  16. : on a csh clone (called GSH, and for the GNO/ME system for the Apple IIgs).
  17.  
  18. Namespace Collision Alert!  There's a gsh program that comes with Perl
  19. and is used by many system administrators to do "global" remote shell
  20. operations.  You thus risk some confusion if you ever plan to port your
  21. program to other Unix systems.
  22.  
  23. : We intend to fix most if not all of these problems as we implement csh
  24. : from scratch on a 16-bit platform.  But I take offense to the manner in 
  25. : which csh's bugs are listed, and then be stated "csh sucks, is 
  26. : totally unworthy", basically.  
  27. :   So, let the flamefest begin.
  28.  
  29. Just because the best defense is a good offense doesn't mean that
  30. your offense is defensible.
  31.  
  32. : > From: Tom Christiansen <tchrist@convex.COM>
  33. :  
  34. : >            Csh Programming Considered Harmful
  35. : > 
  36. : > Resolved: The csh is a tool utterly inadequate for programming, and
  37. : > its use for such purposes should be strictly banned.
  38. :    Oops.  I've used csh scripts before.  Shall I beg forgiveness?
  39.  
  40. That depends on whether you think it's forgivable to shoot yourself in
  41. the foot continually.
  42.  
  43. : > I am continually shocked and dismayed to see people write test cases,
  44. : > install scripts, and other random hackery using the csh.  
  45. :   I am continually shocked and dismayed to see people not have
  46. : command line editing, arrow-key history, job control, or many
  47. : of the other things that csh (tcsh) provides and /bin/sh does not.
  48.  
  49. The title of Tom's missive is "Csh PROGRAMMING Considered Harmful".
  50. You're implicitly assuming that programming environments *ought* to be
  51. confused with interactive environments.  I do not hold this truth to be
  52. self-evident.
  53.  
  54. : > Lack of
  55. : > proficiency in the Bourne shell has been known to cause errors in /etc/rc
  56. : > and .cronrc files, which is a problem, because you *must* write these files
  57. : > in that language.
  58. :   That would seem to be braindamage on the part of the kernel and cron,
  59. : don't you think?
  60.  
  61. It would seem so, but I don't think it.  :-)
  62.  
  63. Historically, csh is the usurper.  And as a programming language it has done
  64. a distinctly lousy job of usurping.
  65.  
  66. The fact is that the Bourne shell provides a more consistent, powerful,
  67. portable and yet lightweight interface for C programs that want to
  68. start shell scripts.  Any C library system() or popen() function that
  69. is correctly implemented will call /bin/sh.  Anything else would induce
  70. total pandemonium and would render many, many programs non-portable.
  71.  
  72. At the height of csh's popularity, The BSD folks goofed and implemented
  73. rsh in terms of csh, and we've been paying the price ever since, over
  74. and over.
  75.  
  76. Hey, I started out being a csh bigot too.  And I still use csh for my
  77. interactive shell.  And I avoid sh programming as much as possible.
  78. You probably don't realize how much I'll do to avoid sh programming...  :-)
  79.  
  80. : > FILE DESCRIPTORS
  81. : > 
  82. : > The most common problem encountered in csh programming is that
  83. : > you can't do file-descriptor manipulation.  All you are able to 
  84. : > do is redirect stdin, or stdout, or dup stderr into stdout. 
  85. : > Bourne-compatible shells offer you an abundance of more exotic
  86. : > possibilities.    
  87. :   Possibilities that could be added to csh, if anyone cared to.
  88.  
  89. Most people don't have the opportunity to fix csh.  Most of us who
  90. have had the opportunity chose to decline it.
  91.  
  92. :   Trivially fixed, by making >& _only_ redirect stderr, and having
  93. : the shell check appropriately for > and >& going to the same file.
  94. : I envison, oh, 10 lines of code? 
  95.  
  96. With 10 lines of code, you've just busted nearly every csh script in
  97. existence.  If you aspire to be a language designer, you'll have to do
  98. better than that.
  99.  
  100. : > You want to know the status of C, well, that's easy: it's in $?, or
  101. : > $status in csh.  But if you want it from A, you're out of luck -- if
  102. : > you're in the csh, that is.  In the Bourne shell, you can get it, although
  103. : > doing so is a bit tricky.  Here's something I had to do where I ran dd's
  104. :    "bit tricky" seems a lot like "totally unsuited to" a task, to me.
  105.  
  106. Now who's thinking in terms of black and white, hmm?
  107.  
  108. A good language design must do two things:  make common things easy,
  109. and hard things possible.  Csh does some of the first, and precious
  110. little of the second.  Hence most csh loyalists turn out to be pretty
  111. green, while us oldsters tend to get a bit more cynical over time...
  112.  
  113. : >     device=/dev/rmt8
  114. : >     dd_noise='^[0-9]+\+[0-9]+ records (in|out)$'
  115. : >     exec 3>&1
  116. : >     status=`((dd if=$device ibs=64k 2>&1 1>&3 3>&- 4>&-; echo $? >&4) |
  117. : >         egrep -v "$dd_noise" 1>&2 3>&- 4>&-) 4>&1`
  118. : >     exit $status;
  119. :   Hmm.  Too bad that's unreadable! :)
  120.  
  121. Unreadable beats unwritable any day.
  122.  
  123. :   "on some systems" means that there's a bug in csh on some systems,
  124. : not that csh is devil-spawn.
  125.  
  126. It's amazing the positive feedback loop that can arise when two hyperbolists
  127. start conversing...
  128.  
  129. : > You can't do this in the csh.  It takes more verbiage.
  130. :   Excuse me?  "You can't do this" and "It takes more verbiage" means
  131. : IT CAN BE DONE.  
  132.  
  133. The pronouns "this" and "it" obviously refer to two different antecedents,
  134. though I suppose a good editor would have asked Tom to clarify it anyway
  135. just for those people who willfully misread things.
  136.  
  137. :   According to you, there exists the possiblity that a lexer smart
  138. : enough to deal with that statement exists, therefore csh is inherently
  139. : flawed because it doesn't implement that lexer?
  140.  
  141. Csh is inherently flawed.  Your program may not be, but then, it appears
  142. to implement a different language.  Hence, Tom's article wasn't about
  143. your language.  Why then are you being so defensive?  :-)
  144.  
  145. : > RANDOM BUGS
  146. :   They're bugs, so they could be fixed.
  147.  
  148. Fine, fix 'em, if you've got a fixation on 'em.
  149.  
  150. : > SUMMARY
  151. : > While some vendors have fixed some of the csh's bugs (the tcsh also does
  152. : > much better here), many have added new ones.  Most of its problems can
  153. : > never be solved because they're not actually bugs per se, but rather the
  154. : > direct consequences of braindead design decisions.  It's inherently flawed.
  155. :   That's garbage.  You have shown no proof for that statement.  I'm
  156. : supposed to read a bug list and then believe that all the bugs are
  157. : caused because csh is "inherently flawed"?
  158.  
  159. It's not so much garbage as hyperbole.  Even Jesus used hyperbole
  160. regularly.  You seem to like to use it upon occasion yourself:
  161.  
  162.     Garbage!  No proof!  All the bugs!
  163.  
  164. Personally, I would never, ever, use hyperbole, but I'll back your right to
  165. use it 110%!!!
  166.  
  167. : > Do yourself a favor, and if you *have* to write a shell script, do it in the
  168. : > Bourne shell.  It's on every UNIX system out there.  However, behavior
  169. : > can vary.
  170. :
  171. :   Gee.. that means that /bin/sh isn't the universal be-all end-all of
  172. : shells?  You don't say?  You mean /bin/sh has bugs?  Really?
  173.  
  174. The basic flaw of Bourne shell is not the presence of bugs, but the
  175. absence of features.  Which means it depends heavily on the health of
  176. every program it has intercourse with.  And most of those programs have
  177. had a pretty sordid history.
  178.  
  179. Csh, being a shell, has some of these same personality problems:
  180. Good for screwing around with and having fun, but watch out for those
  181. second-hand bugs.  Me, I prefer monoprogrammy.
  182.  
  183. : >     Tom Christiansen      tchrist@convex.com      convex!tchrist
  184. : > 
  185. : >     "UNIX was not designed to stop you from doing stupid things, because
  186. : >      that would also stop you from doing clever things." -- Doug Gwyn
  187. :    You're not cool enough to quote Doug Gwyn.
  188.  
  189. Oh, so it's a pissing contest now, is it?  How homo sapient of you.
  190.  
  191. Rool of Cool #1: If you really want people to think you're pretty slick,
  192.          just keep on fighting snot with snot...
  193.  
  194. Personally, I don't care whether someone is cool enough to quote Doug
  195. Gwyn--I only care whether Doug Gwyn is cool enough to quote.
  196.  
  197. And you can quote me on that.
  198.  
  199. : Really; it seems that 'csh sucks' in your opinion because it's not /bin/sh.
  200.  
  201. Csh sucks because it's a lot of things--"not /bin/sh" is just one of them.
  202.  
  203. :    All in all, I'm sorely tempted to grab the existing csh source
  204. : and fix it, but I'll continue on our from-scratch project and 
  205. : do it that way.
  206.  
  207. Good decision.  Had you looked at the csh source, you would not only
  208. have risked madness, but your mind would by now be a wholey-owned
  209. subsidiary of, lesse, who is it these days, Novell, which is madness
  210. enough.
  211.  
  212. :  --Apple II Forever!--
  213.  
  214. Figgers...
  215.  
  216. Love,
  217. Larry Wall
  218. lwall@netlabs.com
  219.  
  220. P.S. Usenet was not designed to stop you from saying stupid things, because
  221.      that would also stop me from saying clever things.
  222.