home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!spool.mu.edu!enterpoop.mit.edu!thunder.mcrcim.mcgill.edu!sobeco!sdesmara
- From: sdesmara@sobeco.com (s.desmarais)
- Subject: Re: The Revenge of CSH
- Organization: Sobeco Ernst & Young
- Date: Thu, 7 Jan 93 14:33:50 GMT
- Message-ID: <1993Jan7.143350.11128@sobeco.com>
- References: <Bzz748.GDK@csn.org> <HUANG1.92Dec29101449@husc11.harvard.edu> <9236508.12113@mulga.cs.mu.OZ.AU>
- Lines: 39
-
- In <9236508.12113@mulga.cs.mu.OZ.AU> fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
-
- >In bash, you can do
- > let i=i+1
- >or you can even declare a particular variable as an integer, in which
- >case all assignments are treated as 'let' statements:
- > declare -i counter
- > ...
- > counter=counter+1
- >but when programming anything more than a one-off, it's usually best
- >to stick to the portable /bin/sh functionality rather than the bash
- >extensions. You get used to i=`expr $i + 1` pretty soon, it's probably
- >no more difficult than getting used to i++ after Pascal's i := i + 1.
-
- Except that "i=`expr $i + 1`" does a fork/exec which can be really
- time consuming inside a loop, especially when many processes are doing
- the same thing. You really need to be carefull, when writing shell
- scripts, about using backquotes and pipes. I got bitten by that with the
- printer interface program we were using on a printer server running
- about 25 postscript printers a 6 matrix printers. I was doing some
- validation using grep, sed, tr, ... It was forking like crazy.
-
- I rewrote the validation step in C, and kept the shell script for the
- remaining. Everything's running smoothly know.
-
- That good old rule: 90% of the time is consumed in 10% of the code...
- ^^^ ^^^ adjust those values
- to suit your needs :-)
-
- >--
- >Fergus Henderson fjh@munta.cs.mu.OZ.AU
- >This .signature virus is a self-referential statement that is true - but
- >you will only be able to consistently believe it if you copy it to your own
- >.signature file!
- --
- Stephane M. Desmarais sdesmara@sobeco.com ou sdesmara@sobeco.ca
- Division STS - Sobeco Ernst & Young {uunet | mcgill-vision}!sobeco.com!sdesmara
- 505 boul Rene-Levesque Ouest bur: (514) 878-9090 poste 297
- Montreal, Quebec CANADA H2Z 1Y7 fax: (514) 875-2673 dom: (514) 251-9418
-