home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.wizards:4770 comp.unix.shell:4765 comp.unix.misc:4234
- Newsgroups: comp.unix.wizards,comp.unix.shell,comp.unix.misc
- 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
- From: peter@ferranti.com (peter da silva)
- Subject: Re: The Problem with UNIX
- Message-ID: <id.JY1V.9KA@ferranti.com>
- Organization: Xenix Support, FICC
- References: <EEIDE.92Nov12120339@asylum.cs.utah.edu> <1992Nov12.193707.27532@chpc.utexas.edu> <-ml1H31!ua@atlantis.psu.edu>
- Date: Wed, 18 Nov 1992 00:22:04 GMT
- Lines: 64
-
- In article <-ml1H31!ua@atlantis.psu.edu> barr@pop.psu.edu (David Barr) writes:
- > >This would all be
- > >solved if there were *one* system function that is used by all programs
- > >instead of having every program duplicate more or less the same
- > >functionality with different success.
-
- > You mean like getopt(3)?
-
- getopt is practically worthless. It doesn't do enough parsing to be worth
- using, and doesn't provide any sort of useful diagnostics. With the example
- in my last message, you'd say:
-
- foo -d
- and get
- foo: required argument to -d (diet) missing.
- Usage: foo [-abc] [-d diet]
-
- And by setting $VERBOSE it'd add
-
- -a Eat an apple.
- -b Eat a banana.
- -c Eat a carrot.
- -d diet Use diet plan in file <diet>
-
- Let's try (this is a slightly older version of the library):
-
- % //xds13/usr1/xds/src/docindex/docindex
- docindex: MasterFile ('master' files) required for -m flag
- docindex: IndexFile ('index' files) required for -i flag
- docindex: HistoryFile ('history' files) required for -h flag
- Usage: docindex -m <MasterFile>... -i <IndexFile>... -h <HistoryFile>... \
- [-p <MsgidPattern>] [-v] [-q]
-
- With the source:
-
- struct arglist *MasterFiles = NULL;
- struct arglist *HistoryFiles = NULL;
- struct arglist *IndexFiles = NULL;
- char *msgid_pattern = "<doc.";
- BOOL Verbose = 0;
- BOOL Quiet = 0;
-
- ARGDESC Args[] =
- {
- 'm', ARGREQ|ARGLIST,listStr, __ &MasterFiles,"MasterFile ('master' files)",
- 'i', ARGREQ|ARGLIST,listStr, __ &IndexFiles,"IndexFile ('index' files)",
- 'h', ARGREQ|ARGLIST,listStr, __ &HistoryFiles,"HistoryFile ('history' files)",
- 'p', ARGOPT, argStr, __&msgid_pattern, "MsgidPattern (magic string for msgid)",
- 'v', ARGOPT, argBool, __&Verbose, "Verbose (report database changes)",
- 'q', ARGOPT, argBool, __&Quiet, "Quiet (about missing data or index files)",
- ENDOFARGS
- };
-
- main(argc, argv)
- int argc;
- char **argv;
- {
- parseargs(argv, Args);
- ...
- --
- Peter da Silva / 77487-5012 USA / +1 713 274 5180
- true(<<VV$@\\$'&O 9$O%'$LT$&$"V6"$&$<4$?'&$ #I&&?$=$<<@)24 24 scale 3 21 moveto
- {dup 36 eq{pop not}{dup 7 and 4 sub exch 56 and 8 div 4 sub 2 index{rlineto}{
- rmoveto}ifelse}ifelse}forall stroke pop showpage % Har du kramat din varg idag?
-