home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.shell:3746 comp.unix.questions:10623
- 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
- From: rayj@Celestial.COM (Ray Jones)
- Newsgroups: comp.unix.shell,comp.unix.questions
- Subject: Re: Shell Scripts vs. C programs
- Keywords: shell script, C
- Message-ID: <1992Sep01.183107.20930@Celestial.COM>
- Date: 1 Sep 92 18:31:07 GMT
- References: <1992Aug31.211738.1909@tjhsst.vak12ed.edu> <la5b90INN6v8@almaak.usc.edu>
- Organization: Celestial Software, Mercer Island, WA
- Lines: 37
-
- In <la5b90INN6v8@almaak.usc.edu> ajayshah@almaak.usc.edu (Ajay Shah) writes:
-
- >nurban@tjhsst () writes:
-
- >>I've heard that if at all possible, code a program as a shell script
- >>rather than coding it in C. Can someone explain the rationale behind
- >>this philosophy?
-
- >It's not so much a rule as a additional design alternative unique to
- >the Unix environment.
-
- >Shell scripts are frequently easy to write (esp. using sed/awk glue).
- >They help in quickly getting a small system running. They are
- >tremendously powerful in automating mundane tasks. In situations
- >where you know you will throw away the code in a few weeks, the
- >shell script approach is almost always better.
-
- >Generally shellscripts are slower than a hand-tuned C program.
- >When the script gets too large, it's easier to debug C instead
- >of sh/sed/awk. There are better debugging tools for C (a
- >weakness of the sh/sed/awk paradigm which sounds fixable to me).
-
- I agree with most of what you said, however, in some cases a shellscript
- is actualy faster (not often, but sometimes). They are much smaller in
- terms of storage space. As to debugging tools, try "sh -x scriptname".
- This will show you every command as it execuites WITH THE SHELL
- SUBSTITUIONS as they occure. If this produces too much information, put
- set -x
- lines of code under question
- set +x # to turn off debuggingh
-
-
- --
- Onager Systems Ray A. Jones
- 18710 NE 59th Ct. UUCP .....uunet!camco!onager!ray
- # 2053 ...ray@onager.Celestial.COM
- Redmond, WA 98052 206-885-3568
-