69 lines
1 KiB
Groff
69 lines
1 KiB
Groff
.
|
|
.TH "GETOPTS" "1" "February 2016" "" "fisherman"
|
|
.
|
|
.SH "NAME"
|
|
\fBgetopts\fR \- Command line options parser
|
|
.
|
|
.SH "SYNOPSIS"
|
|
getopts \fIoptions\fR \.\.\.
|
|
.
|
|
.br
|
|
.
|
|
.SH "DESCRIPTION"
|
|
\fBGetopts\fR is a command line options parser for fish\.
|
|
.
|
|
.SH "USAGE"
|
|
Study the output in the following example
|
|
.
|
|
.IP "" 4
|
|
.
|
|
.nf
|
|
|
|
getopts \-ab1 \-\-foo=bar baz
|
|
.
|
|
.fi
|
|
.
|
|
.IP "" 0
|
|
.
|
|
.IP "" 4
|
|
.
|
|
.nf
|
|
|
|
a
|
|
b 1
|
|
foo bar
|
|
_ baz
|
|
.
|
|
.fi
|
|
.
|
|
.IP "" 0
|
|
.
|
|
.P
|
|
The items on the left are the option flags\. The items on the right are the option values\. The underscore \fB_\fR character is the default \fIkey\fR for bare arguments\.
|
|
.
|
|
.P
|
|
Use read(1) to process the generated stream and switch(1) to match patterns
|
|
.
|
|
.IP "" 4
|
|
.
|
|
.nf
|
|
|
|
getopts \-ab1 \-\-foo=bar baz | while read \-l key option
|
|
switch $key
|
|
case _
|
|
case a
|
|
case b
|
|
case foo
|
|
end
|
|
end
|
|
.
|
|
.fi
|
|
.
|
|
.IP "" 0
|
|
.
|
|
.SH "NOTES"
|
|
.
|
|
.IP "\(bu" 4
|
|
A double dash, \fB\-\-\fR, marks the end of options\. Arguments after this sequence are placed in the default underscore key, \fB_\fR\.
|
|
.
|
|
.IP "" 0
|