diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libc/stdlib/getopt.3 | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/lib/libc/stdlib/getopt.3 b/src/lib/libc/stdlib/getopt.3 index 9b27b70e65..50b756bfbb 100644 --- a/src/lib/libc/stdlib/getopt.3 +++ b/src/lib/libc/stdlib/getopt.3 | |||
| @@ -25,7 +25,7 @@ | |||
| 25 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 26 | .\" SUCH DAMAGE. | 26 | .\" SUCH DAMAGE. |
| 27 | .\" | 27 | .\" |
| 28 | .\" $OpenBSD: getopt.3,v 1.26 2003/09/02 18:24:21 jmc Exp $ | 28 | .\" $OpenBSD: getopt.3,v 1.27 2003/09/18 09:29:27 jmc Exp $ |
| 29 | .\" | 29 | .\" |
| 30 | .Dd December 17, 2002 | 30 | .Dd December 17, 2002 |
| 31 | .Dt GETOPT 3 | 31 | .Dt GETOPT 3 |
| @@ -47,9 +47,11 @@ The | |||
| 47 | .Fn getopt | 47 | .Fn getopt |
| 48 | function incrementally parses a command line argument list | 48 | function incrementally parses a command line argument list |
| 49 | .Fa argv | 49 | .Fa argv |
| 50 | and returns the next known option character. | 50 | and returns the next |
| 51 | .Em known | ||
| 52 | option character. | ||
| 51 | An option character is | 53 | An option character is |
| 52 | .Dq known | 54 | .Em known |
| 53 | if it has been specified in the string of accepted option characters, | 55 | if it has been specified in the string of accepted option characters, |
| 54 | .Fa optstring . | 56 | .Fa optstring . |
| 55 | .Pp | 57 | .Pp |
| @@ -113,7 +115,7 @@ by the option | |||
| 113 | .Ql -- | 115 | .Ql -- |
| 114 | (double dash) which causes | 116 | (double dash) which causes |
| 115 | .Fn getopt | 117 | .Fn getopt |
| 116 | to signal the end of argument processing and returns \-1. | 118 | to signal the end of argument processing and return \-1. |
| 117 | When all options have been processed (i.e., up to the first non-option | 119 | When all options have been processed (i.e., up to the first non-option |
| 118 | argument), | 120 | argument), |
| 119 | .Fn getopt | 121 | .Fn getopt |
| @@ -134,9 +136,9 @@ it returns | |||
| 134 | If | 136 | If |
| 135 | .Fa optstring | 137 | .Fa optstring |
| 136 | has a leading | 138 | has a leading |
| 137 | .Sq \: | 139 | .Sq \&: |
| 138 | then a missing option argument causes | 140 | then a missing option argument causes |
| 139 | .Sq \: | 141 | .Sq \&: |
| 140 | to be returned instead of | 142 | to be returned instead of |
| 141 | .Sq \&? . | 143 | .Sq \&? . |
| 142 | In either case, the variable | 144 | In either case, the variable |
| @@ -147,6 +149,8 @@ The | |||
| 147 | function returns \-1 when the argument list is exhausted. | 149 | function returns \-1 when the argument list is exhausted. |
| 148 | .Sh EXAMPLES | 150 | .Sh EXAMPLES |
| 149 | .Bd -literal -compact | 151 | .Bd -literal -compact |
| 152 | extern char *optarg; | ||
| 153 | extern int optind; | ||
| 150 | int bflag, ch, fd; | 154 | int bflag, ch, fd; |
| 151 | 155 | ||
| 152 | bflag = 0; | 156 | bflag = 0; |
| @@ -174,7 +178,7 @@ argv += optind; | |||
| 174 | If the | 178 | If the |
| 175 | .Fn getopt | 179 | .Fn getopt |
| 176 | function encounters a character not found in the string | 180 | function encounters a character not found in the string |
| 177 | .Va optstring | 181 | .Fa optstring |
| 178 | or detects | 182 | or detects |
| 179 | a missing option argument it writes an error message to | 183 | a missing option argument it writes an error message to |
| 180 | .Em stderr | 184 | .Em stderr |
| @@ -184,7 +188,7 @@ Setting | |||
| 184 | .Va opterr | 188 | .Va opterr |
| 185 | to a zero will disable these error messages. | 189 | to a zero will disable these error messages. |
| 186 | If | 190 | If |
| 187 | .Va optstring | 191 | .Fa optstring |
| 188 | has a leading | 192 | has a leading |
| 189 | .Ql \&: | 193 | .Ql \&: |
| 190 | then a missing option argument causes a | 194 | then a missing option argument causes a |
| @@ -198,7 +202,7 @@ this is reasonable but reduces the amount of error checking possible. | |||
| 198 | .Xr getopt 1 , | 202 | .Xr getopt 1 , |
| 199 | .Xr getopt_long 3 , | 203 | .Xr getopt_long 3 , |
| 200 | .Xr getsubopt 3 | 204 | .Xr getsubopt 3 |
| 201 | .Sh EXTENSIONS | 205 | .Sh STANDARDS |
| 202 | The | 206 | The |
| 203 | .Va optreset | 207 | .Va optreset |
| 204 | variable was added to make it possible to call the | 208 | variable was added to make it possible to call the |
| @@ -223,7 +227,7 @@ This was changed by | |||
| 223 | to decouple | 227 | to decouple |
| 224 | .Fn getopt | 228 | .Fn getopt |
| 225 | from | 229 | from |
| 226 | .Pa <stdio.h> . | 230 | .Aq Pa stdio.h . |
| 227 | .Pp | 231 | .Pp |
| 228 | A single dash | 232 | A single dash |
| 229 | .Pq Ql - | 233 | .Pq Ql - |
