summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2018-08-12 00:08:14 +0000
committerKyle Evans <kevans@FreeBSD.org>2018-08-12 00:08:14 +0000
commit3b89018938ac8773e7432e110ec86f874b876f4f (patch)
treeb8ae87051fa337363d01ec4a328a24965eede75c /lib/libc/stdlib
parent639f40f8e91b0797ed0cac3898e6ed267fd46a79 (diff)
Notes
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r--lib/libc/stdlib/getopt_long.345
1 files changed, 43 insertions, 2 deletions
diff --git a/lib/libc/stdlib/getopt_long.3 b/lib/libc/stdlib/getopt_long.3
index 69047162c5567..021a708d722eb 100644
--- a/lib/libc/stdlib/getopt_long.3
+++ b/lib/libc/stdlib/getopt_long.3
@@ -31,7 +31,7 @@
.\" @(#)getopt.3 8.5 (Berkeley) 4/27/95
.\" $FreeBSD$
.\"
-.Dd December 25, 2011
+.Dd May 2, 2018
.Dt GETOPT_LONG 3
.Os
.Sh NAME
@@ -207,12 +207,53 @@ these functions return 0 and store
.Fa val
in the location pointed to by
.Fa flag .
+.Pp
These functions return
.Ql \&:
-if there was a missing option argument,
+if there was a missing option argument and error messages are suppressed,
.Ql \&?
if the user specified an unknown or ambiguous option, and
\-1 when the argument list has been exhausted.
+The default behavior when a missing option argument is encountered is to write
+an error and return
+.Ql \&? .
+Specifying
+.Ql \&:
+in
+.Fa optstr
+will cause the error message to be suppressed and
+.Ql \&:
+to be returned instead.
+.Pp
+In addition to
+.Ql \&: ,
+a leading
+.Ql \&+
+or
+.Ql \&-
+in
+.Fa optstr
+also has special meaning.
+If either of these are specified, they must appear before
+.Ql \&: .
+.Pp
+A leading
+.Ql \&+
+indicates that processing should be halted at the first non-option argument,
+matching the default behavior of
+.Xr getopt 3 .
+The default behavior without
+.Ql \&+
+is to permute non-option argments to the end of
+.Fa argv .
+.Pp
+A leading
+.Ql \&-
+indicates that all non-option arguments should be treated as if they are
+arguments to a literal
+.Ql \&1
+flag (i.e., the function call will return the value 1, rather than the char
+literal '1').
.Sh ENVIRONMENT
.Bl -tag -width ".Ev POSIXLY_CORRECT"
.It Ev POSIXLY_CORRECT