diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2020-02-16 03:29:05 +0100 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2020-02-16 03:29:05 +0100 |
commit | 94c033d2e281eb1f49e8366d21fc259ce8c0c4f5 (patch) | |
tree | 701ad2fd3a7867e97689d1349d46ca25a92297b4 /Doc/help/getopts | |
parent | 643de931640e01aa246723d2038328ef33737965 (diff) | |
parent | 77d203f3fbbd76386bf197f9776269a1de580bb5 (diff) | |
download | zsh-94c033d2e281eb1f49e8366d21fc259ce8c0c4f5.tar.gz zsh-94c033d2e281eb1f49e8366d21fc259ce8c0c4f5.zip |
New upstream version 5.8
Diffstat (limited to 'Doc/help/getopts')
-rw-r--r-- | Doc/help/getopts | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Doc/help/getopts b/Doc/help/getopts new file mode 100644 index 000000000..ef73c55c1 --- /dev/null +++ b/Doc/help/getopts @@ -0,0 +1,30 @@ +getopts optstring name [ arg ... ] + Checks the args for legal options. If the args are omitted, use + the positional parameters. A valid option argument begins with + a `+' or a `-'. An argument not beginning with a `+' or a `-', + or the argument `--', ends the options. Note that a single `-' + is not considered a valid option argument. optstring contains + the letters that getopts recognizes. If a letter is followed by + a `:', that option requires an argument. The options can be + separated from the argument by blanks. + + Each time it is invoked, getopts places the option letter it + finds in the shell parameter name, prepended with a `+' when arg + begins with a `+'. The index of the next arg is stored in + OPTIND. The option argument, if any, is stored in OPTARG. + + The first option to be examined may be changed by explicitly as- + signing to OPTIND. OPTIND has an initial value of 1, and is + normally set to 1 upon entry to a shell function and restored + upon exit (this is disabled by the POSIX_BUILTINS option). OP- + TARG is not reset and retains its value from the most recent + call to getopts. If either of OPTIND or OPTARG is explicitly + unset, it remains unset, and the index or option argument is not + stored. The option itself is still stored in name in this case. + + A leading `:' in optstring causes getopts to store the letter of + any invalid option in OPTARG, and to set name to `?' for an un- + known option and to `:' when a required argument is missing. + Otherwise, getopts sets name to `?' and prints an error message + when an option is invalid. The exit status is nonzero when + there are no more options. |