You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
fisher/man/man1/getopts.md

45 lines
849 B
Markdown

9 years ago
getopts(1) -- Command line options parser
=========================================
## SYNOPSIS
9 years ago
getopts *options* ...<br>
## DESCRIPTION
9 years ago
**Getopts** is a command line options parser for fish.
## USAGE
9 years ago
Study the output of the following example
```
getopts -ab1 --foo=bar baz
```
```
a
b 1
foo bar
_ baz
```
9 years ago
The items on the left are the option flags. The items on the right are the option values. The underscore `_` character is the default *key* for bare arguments.
9 years ago
Use read(1) to process the generated stream and switch(1) to match patterns
```
getopts -ab1 --foo=bar baz | while read -l key option
switch $key
case _
case a
case b
case foo
end
end
```
9 years ago
## NOTES
* A double dash, `--`, marks the end of options. Arguments after this sequence are placed in the default underscore key, `_`.