2016-02-27 06:27:17 +00:00
getopts(1) -- Command line options parser
=========================================
2016-01-01 21:12:40 +00:00
## SYNOPSIS
2016-02-27 06:27:17 +00:00
getopts *options* ...< br >
2016-01-01 21:12:40 +00:00
## DESCRIPTION
2016-02-20 13:19:25 +00:00
**Getopts** is a command line options parser for fish.
2016-01-01 21:12:40 +00:00
## USAGE
2016-03-11 21:45:17 +00:00
Study the output of getopts in the following example
2016-01-01 21:12:40 +00:00
```
getopts -ab1 --foo=bar baz
```
```
a
b 1
foo bar
_ baz
```
2016-03-11 21:45:17 +00:00
The items on the left are the command option *keys* . The items on the right are the option *values* . The underscore `_` character is the default key for bare arguments.
2016-01-01 21:12:40 +00:00
```
getopts -ab1 --foo=bar baz | while read -l key option
switch $key
case _
case a
case b
case foo
end
end
```
2016-02-20 13:19:25 +00:00
## NOTES
2016-01-01 21:12:40 +00:00
* A double dash, `--` , marks the end of options. Arguments after this sequence are placed in the default underscore key, `_` .