| Server IP : 217.160.0.244 / Your IP : 216.73.217.138 Web Server : Apache System : Linux infong-eu155 4.4.400-icpu-108 #2 SMP Wed Feb 11 11:51:01 UTC 2026 x86_64 User : u100174116 ( 6746176) PHP Version : 8.5.10 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /usr/share/zsh/help/ |
Upload File : |
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 sepa-
rated 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 nor-
mally set to 1 upon entry to a shell function and restored upon
exit. (The POSIX_BUILTINS option disables this, and also changes
the way the value is calculated to match other shells.) OPTARG
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.