diff options
Diffstat (limited to 'src/lib/libc/stdlib/getopt.3')
-rw-r--r-- | src/lib/libc/stdlib/getopt.3 | 33 |
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 |
52 | function incrementally parses a command line argument list | 52 | function incrementally parses a command line argument list |
53 | .Fa argv | 53 | .Fa argv |
54 | and returns the next | 54 | and returns the next known option character. |
55 | .Em known | ||
56 | option character. | ||
57 | An option character is | 55 | An option character is |
58 | .Em known | 56 | .Dq known |
59 | if it has been specified in the string of accepted option characters, | 57 | if it has been specified in the string of accepted option characters, |
60 | .Fa optstring . | 58 | .Fa optstring . |
61 | .Pp | 59 | .Pp |
62 | The option string | 60 | The option string |
63 | .Fa optstring | 61 | .Fa optstring |
64 | may contain the following elements: individual characters, and | 62 | may contain the following elements: individual characters and |
65 | characters followed by a colon to indicate an option argument | 63 | characters followed by a colon to indicate an option argument |
66 | is to follow. | 64 | is to follow. |
67 | For example, an option string | 65 | For example, an option string |
68 | .Li "\&""x"" | 66 | .Qq x |
69 | recognizes an option | 67 | recognizes an option |
70 | .Dq Fl x , | 68 | .Fl x , |
71 | and an option string | 69 | and an option string |
72 | .Li "\&""x:"" | 70 | .Qq Li x: |
73 | recognizes an option and argument | 71 | recognizes an option and argument |
74 | .Dq Fl x Ar argument . | 72 | .Fl x Ar argument . |
75 | It does not matter to | 73 | It does not matter to |
76 | .Fn getopt | 74 | .Fn getopt |
77 | if a following argument has leading whitespace. | 75 | if a following argument has leading whitespace. |
@@ -89,12 +87,10 @@ to | |||
89 | .Fn getopt . | 87 | .Fn getopt . |
90 | The variable | 88 | The variable |
91 | .Va optopt | 89 | .Va optopt |
92 | saves the last | 90 | saves the last known option character returned by |
93 | .Em known | ||
94 | option character returned by | ||
95 | .Fn getopt . | 91 | .Fn getopt . |
96 | .Pp | 92 | .Pp |
97 | The variable | 93 | The variables |
98 | .Va opterr | 94 | .Va opterr |
99 | and | 95 | and |
100 | .Va optind | 96 | .Va optind |
@@ -119,9 +115,7 @@ must be reinitialized. | |||
119 | .Pp | 115 | .Pp |
120 | The | 116 | The |
121 | .Fn getopt | 117 | .Fn getopt |
122 | function | 118 | function returns \-1 when the argument list is exhausted. |
123 | returns \-1 | ||
124 | when the argument list is exhausted. | ||
125 | The interpretation of options in the argument list may be cancelled | 119 | The interpretation of options in the argument list may be cancelled |
126 | by the option | 120 | by the option |
127 | .Ql -- | 121 | .Ql -- |
@@ -157,9 +151,8 @@ then a missing option argument causes a | |||
157 | to be returned in addition to suppressing any error messages. | 151 | to be returned in addition to suppressing any error messages. |
158 | .Pp | 152 | .Pp |
159 | Option arguments are allowed to begin with | 153 | Option arguments are allowed to begin with |
160 | .Dq Li \- ; | 154 | .Ql - ; |
161 | this is reasonable but | 155 | this is reasonable but reduces the amount of error checking possible. |
162 | reduces the amount of error checking possible. | ||
163 | .Sh EXTENSIONS | 156 | .Sh EXTENSIONS |
164 | The | 157 | The |
165 | .Va optreset | 158 | .Va optreset |