home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / shell / 3746 < prev    next >
Encoding:
Internet Message Format  |  1992-09-01  |  2.1 KB

  1. Xref: sparky comp.unix.shell:3746 comp.unix.questions:10623
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!rpi!usenet.coe.montana.edu!news.u.washington.edu!sumax!thebes!camco!Celestial.COM!rayj
  3. From: rayj@Celestial.COM (Ray Jones)
  4. Newsgroups: comp.unix.shell,comp.unix.questions
  5. Subject: Re: Shell Scripts vs. C programs
  6. Keywords: shell script, C
  7. Message-ID: <1992Sep01.183107.20930@Celestial.COM>
  8. Date: 1 Sep 92 18:31:07 GMT
  9. References: <1992Aug31.211738.1909@tjhsst.vak12ed.edu> <la5b90INN6v8@almaak.usc.edu>
  10. Organization: Celestial Software, Mercer Island, WA
  11. Lines: 37
  12.  
  13. In <la5b90INN6v8@almaak.usc.edu> ajayshah@almaak.usc.edu (Ajay Shah) writes:
  14.  
  15. >nurban@tjhsst () writes:
  16.  
  17. >>I've heard that if at all possible, code a program as a shell script
  18. >>rather than coding it in C.  Can someone explain the rationale behind
  19. >>this philosophy?
  20.  
  21. >It's not so much a rule as a additional design alternative unique to
  22. >the Unix environment.
  23.  
  24. >Shell scripts are frequently easy to write (esp. using sed/awk glue).
  25. >They help in quickly getting a small system running.  They are
  26. >tremendously powerful in automating mundane tasks.  In situations
  27. >where you know you will throw away the code in a few weeks, the
  28. >shell script approach is almost always better.
  29.  
  30. >Generally shellscripts are slower than a hand-tuned C program.
  31. >When the script gets too large, it's easier to debug C instead
  32. >of sh/sed/awk.  There are better debugging tools for C (a
  33. >weakness of the sh/sed/awk paradigm which sounds fixable to me).
  34.  
  35. I agree with most of what you said, however, in some cases a shellscript
  36. is actualy faster (not often, but sometimes).  They are much smaller in
  37. terms of storage space.  As to debugging tools, try "sh -x scriptname".
  38. This will show you every command as it execuites WITH THE SHELL
  39. SUBSTITUIONS as they occure.  If this produces too much information, put
  40. set -x
  41. lines of code under question
  42. set +x  # to turn off debuggingh
  43.  
  44.  
  45. -- 
  46. Onager Systems             Ray A. Jones
  47. 18710 NE 59th Ct.        UUCP .....uunet!camco!onager!ray
  48. # 2053                   ...ray@onager.Celestial.COM
  49. Redmond, WA 98052               206-885-3568 
  50.