summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/getopt.3
diff options
context:
space:
mode:
authoraaron <>2000-04-20 13:50:03 +0000
committeraaron <>2000-04-20 13:50:03 +0000
commita4336f357f9e30dffdfad4909b24bd2e82c096a2 (patch)
treec79a224a41eb2c48668c4b4eda84163d7daadf64 /src/lib/libc/stdlib/getopt.3
parent92b3e44bedaf5a5f85880565a47206cdbf9bfa2a (diff)
downloadopenbsd-a4336f357f9e30dffdfad4909b24bd2e82c096a2.tar.gz
openbsd-a4336f357f9e30dffdfad4909b24bd2e82c096a2.tar.bz2
openbsd-a4336f357f9e30dffdfad4909b24bd2e82c096a2.zip
Flesh out stdlib function man pages.
Diffstat (limited to 'src/lib/libc/stdlib/getopt.3')
-rw-r--r--src/lib/libc/stdlib/getopt.333
1 files changed, 13 insertions, 20 deletions
diff --git a/src/lib/libc/stdlib/getopt.3 b/src/lib/libc/stdlib/getopt.3
index 637a81f1f0..ef132cafc5 100644
--- a/src/lib/libc/stdlib/getopt.3
+++ b/src/lib/libc/stdlib/getopt.3
@@ -29,7 +29,7 @@
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE. 30.\" SUCH DAMAGE.
31.\" 31.\"
32.\" $OpenBSD: getopt.3,v 1.12 2000/03/04 22:19:31 aaron Exp $ 32.\" $OpenBSD: getopt.3,v 1.13 2000/04/20 13:50:02 aaron Exp $
33.\" 33.\"
34.Dd April 19, 1994 34.Dd April 19, 1994
35.Dt GETOPT 3 35.Dt GETOPT 3
@@ -51,27 +51,25 @@ The
51.Fn getopt 51.Fn getopt
52function incrementally parses a command line argument list 52function incrementally parses a command line argument list
53.Fa argv 53.Fa argv
54and returns the next 54and returns the next known option character.
55.Em known
56option character.
57An option character is 55An option character is
58.Em known 56.Dq known
59if it has been specified in the string of accepted option characters, 57if it has been specified in the string of accepted option characters,
60.Fa optstring . 58.Fa optstring .
61.Pp 59.Pp
62The option string 60The option string
63.Fa optstring 61.Fa optstring
64may contain the following elements: individual characters, and 62may contain the following elements: individual characters and
65characters followed by a colon to indicate an option argument 63characters followed by a colon to indicate an option argument
66is to follow. 64is to follow.
67For example, an option string 65For example, an option string
68.Li "\&""x"" 66.Qq x
69recognizes an option 67recognizes an option
70.Dq Fl x , 68.Fl x ,
71and an option string 69and an option string
72.Li "\&""x:"" 70.Qq Li x:
73recognizes an option and argument 71recognizes an option and argument
74.Dq Fl x Ar argument . 72.Fl x Ar argument .
75It does not matter to 73It does not matter to
76.Fn getopt 74.Fn getopt
77if a following argument has leading whitespace. 75if a following argument has leading whitespace.
@@ -89,12 +87,10 @@ to
89.Fn getopt . 87.Fn getopt .
90The variable 88The variable
91.Va optopt 89.Va optopt
92saves the last 90saves the last known option character returned by
93.Em known
94option character returned by
95.Fn getopt . 91.Fn getopt .
96.Pp 92.Pp
97The variable 93The variables
98.Va opterr 94.Va opterr
99and 95and
100.Va optind 96.Va optind
@@ -119,9 +115,7 @@ must be reinitialized.
119.Pp 115.Pp
120The 116The
121.Fn getopt 117.Fn getopt
122function 118function returns \-1 when the argument list is exhausted.
123returns \-1
124when the argument list is exhausted.
125The interpretation of options in the argument list may be cancelled 119The interpretation of options in the argument list may be cancelled
126by the option 120by the option
127.Ql -- 121.Ql --
@@ -157,9 +151,8 @@ then a missing option argument causes a
157to be returned in addition to suppressing any error messages. 151to be returned in addition to suppressing any error messages.
158.Pp 152.Pp
159Option arguments are allowed to begin with 153Option arguments are allowed to begin with
160.Dq Li \- ; 154.Ql - ;
161this is reasonable but 155this is reasonable but reduces the amount of error checking possible.
162reduces the amount of error checking possible.
163.Sh EXTENSIONS 156.Sh EXTENSIONS
164The 157The
165.Va optreset 158.Va optreset