Annotation of coherent/a/usr/man/COHERENT/getopts, revision 1.1.1.1

1.1       root        1: 
                      2: 
                      3: getopts                      Command                      getopts
                      4: 
                      5: 
                      6: 
                      7: 
                      8: Parse command-line options
                      9: 
                     10: ggeettooppttss _o_p_t_s_t_r_i_n_g _n_a_m_e [ _o_p_t ]
                     11: 
                     12: The command  ggeettooppttss is available  under the Korn kksshh  to parse a
                     13: command's  options  and  check  their legality.   _o_p_t_s_t_r_i_n_g  must
                     14: contain the  options letters that the  command using ggeettooppttss will
                     15: recognize.  If  a letter is followed by a  colon `:', that option
                     16: must have an argument that is separated from it by whitespace.
                     17: 
                     18: Each time it is invoked,  ggeettooppttss places the next option into the
                     19: shell  variable _n_a_m_e  and the  index of the  next argument  to be
                     20: processed into the shell variable OOPPTTIINNDD, which is initialized by
                     21: default  to one.   When an option  requires an  argument, ggeettooppttss
                     22: copies it  into the shell variable  OOPPTTAARRGG. If ggeettooppttss encounters
                     23: an error, it initializes variable _n_a_m_e to ?.
                     24: 
                     25: When it  encounters the  end of  the options, ggeettooppttss  exits with
                     26: non-zero  status.   The  special option  ``--''  can  be used  to
                     27: delineate the end of options.
                     28: 
                     29: ***** Example *****
                     30: 
                     31: The following  example processes a command  that takes options aa,
                     32: bb, and oo; the last option requires an argument:
                     33: 
                     34: 
                     35:         while getopts abo: c
                     36:         do
                     37:                 case $c in
                     38:                         a|b)    FLAGS=$FLAGS$c;;
                     39:                         o)      OARG=$OPTARG;;
                     40:                         \?)     echo $USAGE 1>&2
                     41:                                 exit 2;;
                     42:                 esac
                     43:         done
                     44:         shift OPTIND-1
                     45: 
                     46: 
                     47: This code will accept any of the following as equivalent:
                     48: 
                     49: 
                     50:         cmd -a -b -o "xxx z yy" file
                     51:         cmd -a -b -o "xxx z yy" -- file
                     52:         cmd -ab -o "xxx z yy" file
                     53:         cmd -ab -o "xxx z yy" -- file
                     54: 
                     55: 
                     56: ***** See Also *****
                     57: 
                     58: ccoommmmaannddss, ggeettoopptt(), kksshh
                     59: 
                     60: 
                     61: 
                     62: 
                     63: 
                     64: COHERENT Lexicon                                           Page 1
                     65: 
                     66: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.