Autzoo.1288
net.sources
utcsrgv!utzoo!henry
Tue Jan 19 03:22:25 1982
getopt(1)
The following is the source and manual page for a getopt program
(for use in shell programming) written locally to match the description
in a copy of the Unix 3.0 manual that I got to see once.  Behavior is
believed identical to the Bell one, but this is NOT Bell code and
carries no nondisclosure restrictions.  Use it on any system you wish.
NB unlike the previous getopt(3), this has not been too well shaken down.
-----------
#include <STDIO.H>

main(argc, argv)
int argc;
char *argv[];
{
       extern int optind;
       extern char *optarg;
       int c;
       int status = 0;

       optind = 2;     /* Past the program name and the option letters. */
       while ((c = getopt(argc, argv, argv[1])) != EOF)
               switch (c) {
               case '?':
                       status = 1;     /* getopt routine gave message */
                       break;
               default:
                       if (optarg != NULL)
                               printf(" -%c %s", c, optarg);
                       else
                               printf(" -%c", c);
                       break;
               }
       printf(" --");
       for (; optind
<HR>
This Usenet Oldnews Archive
article may be copied and distributed freely, provided:
<P>
1. There is no money collected for the text(s) of the articles.
<BR>
2. The following notice remains appended to each copy:
<P>
<EM>The Usenet Oldnews Archive: Compilation Copyright&copy 1981, 1996
<BR> Bruce Jones, Henry Spencer, David Wiseman.</EM>
<P>
<HR>
Goto <A HREF="82.02.19_utah-gr.149_net.sources.html">NEXT</A> article in NET.sources Newsgroup
<BR>Return to <A HREF="NET.sources-index.html">NET.sources index</A>
<BR>Return to the
       <A HREF="../index.html">Usenet Oldnews Archive index</A>
</HTML>

-----------------------------------------------------------------
gopher://quux.org/ conversion by John Goerzen <[email protected]>
of http://communication.ucsd.edu/A-News/


This Usenet Oldnews Archive
article may be copied and distributed freely, provided:

1. There is no money collected for the text(s) of the articles.

2. The following notice remains appended to each copy:

The Usenet Oldnews Archive: Compilation Copyright (C) 1981, 1996
Bruce Jones, Henry Spencer, David Wiseman.