home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / question / 15259 < prev    next >
Encoding:
Text File  |  1993-01-07  |  2.3 KB  |  50 lines

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