home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / unix / shell / 5117 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  1.6 KB

  1. Xref: sparky comp.unix.shell:5117 comp.unix.questions:14830 comp.unix.admin:6728
  2. Newsgroups: comp.unix.shell,comp.unix.questions,comp.unix.admin
  3. Path: sparky!uunet!cs.utexas.edu!torn!utgpu!credit.erin.utoronto.ca!glover
  4. From: glover@credit.erin.utoronto.ca (Mike Glover)
  5. Subject: Re: Need HELP with functions in SH shell programming!       
  6. Message-ID: <1992Dec19.225621.5797@credit.erin.utoronto.ca>
  7. Organization: University of Toronto, Erindale Campus
  8. References: <EJH.92Dec10164940@khonshu.colorado.edu> <1992Dec18.154617.14831@acd4.acd.com>
  9. Date: Sat, 19 Dec 1992 22:56:21 GMT
  10. Lines: 35
  11.  
  12. In article <1992Dec18.154617.14831@acd4.acd.com> greene@IEDV4.acd.com ( Jonathan Greene ) writes:
  13. >Hi.  I've written a shell script for the SH shell, and would like
  14. >to combine the the 2 places I have the same case statements into 
  15. >into 1, by means of a function.
  16. >
  17. >The manual says a function is defined by:
  18. >  
  19. >name () {list;} where name is the name of the function and
  20. >list is the list of commands you want the function to execute.
  21. >
  22. >When I execute the script, I get the error: '(' Unexpected.
  23. >I also can't figure out the correct way to call the function. 
  24. >
  25.  
  26. Try this little script and if it doesn't work mail me back (to save bandwidth)
  27.  
  28. ========= 8<  cut here
  29. #!/bin/sh
  30. name() {
  31.     echo hi
  32. }
  33. name
  34.  
  35. ======
  36.  
  37. This,  when  run should echo hi.  If it works,  then take it from there. :)
  38.  
  39. ttfn,
  40.     Mike
  41.  
  42. -- 
  43. _______________________________________________________________________________
  44.  ___                    "Mickey Mouse wears a timex watch."_ ???
  45.  U|             glover@credit.erin.utoronto.ca  (Mike Glover)
  46.  C|S            University of Toronto Computing Services
  47.