home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / unix / wizards / 4770 < prev    next >
Encoding:
Text File  |  1992-11-17  |  2.7 KB  |  76 lines

  1. Xref: sparky comp.unix.wizards:4770 comp.unix.shell:4765 comp.unix.misc:4234
  2. Newsgroups: comp.unix.wizards,comp.unix.shell,comp.unix.misc
  3. Path: sparky!uunet!ferkel.ucsb.edu!taco!rock!stanford.edu!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!menudo.uh.edu!sugar!ficc!peter
  4. From: peter@ferranti.com (peter da silva)
  5. Subject: Re: The Problem with UNIX
  6. Message-ID: <id.JY1V.9KA@ferranti.com>
  7. Organization: Xenix Support, FICC
  8. References: <EEIDE.92Nov12120339@asylum.cs.utah.edu> <1992Nov12.193707.27532@chpc.utexas.edu> <-ml1H31!ua@atlantis.psu.edu>
  9. Date: Wed, 18 Nov 1992 00:22:04 GMT
  10. Lines: 64
  11.  
  12. In article <-ml1H31!ua@atlantis.psu.edu> barr@pop.psu.edu (David Barr) writes:
  13. > >This would all be
  14. > >solved if there were *one* system function that is used by all programs
  15. > >instead of having every program duplicate more or less the same
  16. > >functionality with different success.
  17.  
  18. > You mean like getopt(3)?
  19.  
  20. getopt is practically worthless. It doesn't do enough parsing to be worth
  21. using, and doesn't provide any sort of useful diagnostics. With the example
  22. in my last message, you'd say:
  23.  
  24.     foo -d
  25. and get
  26.     foo: required argument to -d (diet) missing.
  27.     Usage: foo [-abc] [-d diet]
  28.  
  29. And by setting $VERBOSE it'd add 
  30.  
  31.         -a    Eat an apple.
  32.         -b    Eat a banana.
  33.         -c    Eat a carrot.
  34.         -d diet    Use diet plan in file <diet>
  35.  
  36. Let's try (this is a slightly older version of the library):
  37.  
  38. % //xds13/usr1/xds/src/docindex/docindex
  39. docindex: MasterFile ('master' files) required for -m flag
  40. docindex: IndexFile ('index' files) required for -i flag
  41. docindex: HistoryFile ('history' files) required for -h flag
  42. Usage: docindex -m <MasterFile>... -i <IndexFile>... -h <HistoryFile>... \
  43.     [-p <MsgidPattern>] [-v] [-q]
  44.  
  45. With the source:
  46.  
  47. struct arglist *MasterFiles = NULL;
  48. struct arglist *HistoryFiles = NULL;
  49. struct arglist *IndexFiles = NULL;
  50. char *msgid_pattern = "<doc.";
  51. BOOL Verbose = 0;
  52. BOOL Quiet = 0;
  53.  
  54. ARGDESC    Args[] =
  55. {
  56. 'm', ARGREQ|ARGLIST,listStr, __ &MasterFiles,"MasterFile ('master' files)",
  57. 'i', ARGREQ|ARGLIST,listStr, __ &IndexFiles,"IndexFile ('index' files)",
  58. 'h', ARGREQ|ARGLIST,listStr, __ &HistoryFiles,"HistoryFile ('history' files)",
  59. 'p', ARGOPT, argStr, __&msgid_pattern, "MsgidPattern (magic string for msgid)",
  60. 'v', ARGOPT, argBool, __&Verbose, "Verbose (report database changes)",
  61. 'q', ARGOPT, argBool, __&Quiet, "Quiet (about missing data or index files)",
  62. ENDOFARGS
  63. };
  64.  
  65. main(argc, argv)
  66.     int argc;
  67.     char **argv;
  68. {
  69.     parseargs(argv, Args);
  70.     ...
  71. -- 
  72. Peter da Silva / 77487-5012 USA / +1 713 274 5180
  73. true(<<VV$@\\$'&O 9$O%'$LT$&$"V6"$&$<4$?'&$ #I&&?$=$<<@)24 24 scale 3 21 moveto
  74. {dup 36 eq{pop not}{dup 7 and 4 sub exch 56 and 8 div 4 sub 2 index{rlineto}{
  75. rmoveto}ifelse}ifelse}forall stroke pop showpage % Har du kramat din varg idag?
  76.