Table of Contents
Previous Utility | List of External Utilities | Next Utility

Getopt


        Parse Command-Line Options

Usage:  getopt [-hq-] [-c cmdname] optiondesc argument ...

   getopt is used in shell scripts for parsing command line
   options into a canonical form, where each option is presented
   in a separate word and any option that takes an argument has
   the argument given in the next word.  Each option word starts
   with '-' and a word consisting only of '--' separates the last
   option from any remaining arguments.

   Scanning for options stops at the first argument which does
   not begin with '-' or '/' or which consists only of '--' or
   '//'.  The SWITCHCHARS environment variable may be used to
   specify a different set of characters other than '-' or '/'
   as the option switch characters to be recognized on input.
   (On output, '-' is always used, never anything else, purely
   to simplify writing the script.)


Options:

   -h           Help.  (This screen.)
   -q           Enclose any output words containing C shell word
                separator characters inside double quotes so that
                the word will not be split up when assigning it
                to a variable in a script.  The word separators
                are:  space, (, ), ;, |, &, <, >, \n, \r and \t.

                Note:  This option is normally used with eval, e.g.,

                  eval set args = `getopt -q ...`

   -c cmdname   Any error messages that are produced should say
                they were generated by cmdname, not getopt.
   --           End of options.



Previous Utility | List of External Utilities | Next Utility
Table of Contents



Copyright © 1988-2003 by Hamilton Laboratories. All rights reserved.