VMS Help  —  CRTL  getopt  Description
    The variable optind is the index of the next element of the
    argv vector to be processed. It is initialized to 1 by the
    system, and it is updated by getopt when it finishes with each
    element of argv. When an element of argv contains multiple option
    characters, it is unspecified how getopt determines which options
    have already been processed.

    The getopt function returns the next option character (if one is
    found) from argv that matches a character in optstring, if there
    is one that matches. If the option takes an argument, getopt sets
    the variable optarg to point to the option-argument as follows:

    o  If the option was the last character in the string pointed to
       by an element of argv, then optarg contains the next element
       of argv, and optind is incremented by 2. If the resulting
       value of optind is not less than argc, getopt returns an
       error, indicating a missing option-argument.

    o  Otherwise, optarg points to the string following the option
       character in that element of argv, and optind is incremented
       by 1.

    If one of the following is true, getopt returns -1 without
    changing optind:

       argv[optind] is a NULL pointer
       *argv[optind] is not the character -
       argv[optind] points to the string "-"

    If argv[optind] points to the string "- -" getopt returns -1
    after incrementing optind.

    If getopt encounters an option character not contained in
    optstring, the question-mark character (?)  is returned.

    If getopt detects a missing argument, the colon character (:)
    is returned if the first character of optstring is a colon;
    otherwise, a question-mark character is returned.

    In either of the previous two cases, getopt sets the variable
    optopt to the option character that caused the error. If the
    application has not set the variable opterr to 0 and the first
    character of optstring is not a colon, getopt also prints a
    diagnostic message to stderr.
Close Help