]>
Commit | Line | Data |
---|---|---|
bf5a7247 | 1 | .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de) |
fea681da | 2 | .\" |
93015253 | 3 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
4 | .\" Permission is granted to make and distribute verbatim copies of this |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
c13182ef | 12 | .\" |
fea681da MK |
13 | .\" Since the Linux kernel and libraries are constantly changing, this |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | .\" responsibility for errors or omissions, or for damages resulting from | |
16 | .\" the use of the information contained herein. The author(s) may not | |
17 | .\" have taken the same level of care in the production of this manual, | |
18 | .\" which is licensed free of charge, as they might when working | |
19 | .\" professionally. | |
c13182ef | 20 | .\" |
fea681da MK |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 23 | .\" %%%LICENSE_END |
c08df37a | 24 | .\" |
fea681da MK |
25 | .\" Modified Sat Jul 24 19:27:50 1993 by Rik Faith (faith@cs.unc.edu) |
26 | .\" Modified Mon Aug 30 22:02:34 1995 by Jim Van Zandt <jrv@vanzandt.mv.com> | |
27 | .\" longindex is a pointer, has_arg can take 3 values, using consistent | |
28 | .\" names for optstring and longindex, "\n" in formats fixed. Documenting | |
29 | .\" opterr and getopt_long_only. Clarified explanations (borrowing heavily | |
30 | .\" from the source code). | |
31 | .\" Modified 8 May 1998 by Joseph S. Myers (jsm28@cam.ac.uk) | |
32 | .\" Modified 990715, aeb: changed `EOF' into `-1' since that is what POSIX | |
33 | .\" says; moreover, EOF is not defined in <unistd.h>. | |
f74bac5d | 34 | .\" Modified 2002-02-16, joey: added information about nonexistent |
fea681da | 35 | .\" option character and colon as first option character |
c11b1abf | 36 | .\" Modified 2004-07-28, Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da MK |
37 | .\" Added text to explain how to order both '[-+]' and ':' at |
38 | .\" the start of optstring | |
92e014f6 | 39 | .\" Modified 2006-12-15, mtk, Added getopt() example program. |
fea681da | 40 | .\" |
460495ca | 41 | .TH GETOPT 3 2015-08-08 "GNU" "Linux Programmer's Manual" |
fea681da | 42 | .SH NAME |
57db674d MK |
43 | getopt, getopt_long, getopt_long_only, |
44 | optarg, optind, opterr, optopt \- Parse command-line options | |
fea681da MK |
45 | .SH SYNOPSIS |
46 | .nf | |
47 | .B #include <unistd.h> | |
48 | .sp | |
49 | .BI "int getopt(int " argc ", char * const " argv[] , | |
50 | .BI " const char *" optstring ); | |
51 | .sp | |
52 | .BI "extern char *" optarg ; | |
53 | .BI "extern int " optind ", " opterr ", " optopt ; | |
54 | .sp | |
fea681da MK |
55 | .B #include <getopt.h> |
56 | .sp | |
57 | .BI "int getopt_long(int " argc ", char * const " argv[] , | |
58 | .BI " const char *" optstring , | |
59 | .BI " const struct option *" longopts ", int *" longindex ); | |
60 | .sp | |
61 | .BI "int getopt_long_only(int " argc ", char * const " argv[] , | |
62 | .BI " const char *" optstring , | |
63 | .BI " const struct option *" longopts ", int *" longindex ); | |
64 | .fi | |
0f200f07 MK |
65 | .sp |
66 | .in -4n | |
67 | Feature Test Macro Requirements for glibc (see | |
68 | .BR feature_test_macros (7)): | |
69 | .ad l | |
70 | .in | |
71 | .sp | |
72 | .BR getopt (): | |
0b8ff556 | 73 | _POSIX_C_SOURCE\ >=\ 2 || _XOPEN_SOURCE |
0f200f07 MK |
74 | .br |
75 | .BR getopt_long (), | |
76 | .BR getopt_long_only (): | |
77 | _GNU_SOURCE | |
78 | .ad b | |
fea681da MK |
79 | .SH DESCRIPTION |
80 | The | |
f10e4102 | 81 | .BR getopt () |
c13182ef MK |
82 | function parses the command-line arguments. |
83 | Its arguments | |
fea681da MK |
84 | .I argc |
85 | and | |
86 | .I argv | |
87 | are the argument count and array as passed to the | |
63aa9df0 | 88 | .IR main () |
fea681da | 89 | function on program invocation. |
f81fb444 | 90 | An element of \fIargv\fP that starts with \(aq\-\(aq |
fea681da | 91 | (and is not exactly "\-" or "\-\-") |
c13182ef MK |
92 | is an option element. |
93 | The characters of this element | |
f81fb444 | 94 | (aside from the initial \(aq\-\(aq) are option characters. |
60a90ecd MK |
95 | If |
96 | .BR getopt () | |
fea681da MK |
97 | is called repeatedly, it returns successively each of the option characters |
98 | from each of the option elements. | |
99 | .PP | |
66b08231 MK |
100 | The variable |
101 | .I optind | |
102 | is the index of the next element to be processed in | |
103 | .IR argv . | |
104 | The system initializes this value to 1. | |
105 | The caller can reset it to 1 to restart scanning of the same | |
106 | .IR argv , | |
107 | or when scanning a new argument vector. | |
108 | .PP | |
60a90ecd MK |
109 | If |
110 | .BR getopt () | |
111 | finds another option character, it returns that | |
fea681da | 112 | character, updating the external variable \fIoptind\fP and a static |
60a90ecd MK |
113 | variable \fInextchar\fP so that the next call to |
114 | .BR getopt () | |
115 | can | |
fea681da MK |
116 | resume the scan with the following option character or |
117 | \fIargv\fP-element. | |
118 | .PP | |
60a90ecd MK |
119 | If there are no more option characters, |
120 | .BR getopt () | |
121 | returns \-1. | |
fea681da MK |
122 | Then \fIoptind\fP is the index in \fIargv\fP of the first |
123 | \fIargv\fP-element that is not an option. | |
124 | .PP | |
125 | .I optstring | |
c13182ef MK |
126 | is a string containing the legitimate option characters. |
127 | If such a | |
fea681da | 128 | character is followed by a colon, the option requires an argument, so |
60a90ecd MK |
129 | .BR getopt () |
130 | places a pointer to the following text in the same | |
fea681da MK |
131 | \fIargv\fP-element, or the text of the following \fIargv\fP-element, in |
132 | .IR optarg . | |
133 | Two colons mean an option takes | |
e6bcc128 | 134 | an optional arg; if there is text in the current \fIargv\fP-element |
f262c004 | 135 | (i.e., in the same word as the option name itself, for example, "\-oarg"), |
e6bcc128 | 136 | then it is returned in \fIoptarg\fP, otherwise \fIoptarg\fP is set to zero. |
c13182ef MK |
137 | This is a GNU extension. |
138 | If | |
fea681da MK |
139 | .I optstring |
140 | contains | |
141 | .B W | |
142 | followed by a semicolon, then | |
143 | .B \-W foo | |
144 | is treated as the long option | |
145 | .BR \-\-foo . | |
146 | (The | |
147 | .B \-W | |
148 | option is reserved by POSIX.2 for implementation extensions.) | |
d9bfdb9c | 149 | This behavior is a GNU extension, not available with libraries before |
5260fe08 | 150 | glibc 2. |
fea681da | 151 | .PP |
60a90ecd MK |
152 | By default, |
153 | .BR getopt () | |
154 | permutes the contents of \fIargv\fP as it | |
24b74457 | 155 | scans, so that eventually all the nonoptions are at the end. |
c13182ef MK |
156 | Two other modes are also implemented. |
157 | If the first character of | |
f81fb444 | 158 | \fIoptstring\fP is \(aq+\(aq or the environment variable |
d9a10d9d | 159 | .B POSIXLY_CORRECT |
24b74457 | 160 | is set, then option processing stops as soon as a nonoption argument is |
c13182ef | 161 | encountered. |
f81fb444 | 162 | If the first character of \fIoptstring\fP is \(aq\-\(aq, then |
24b74457 | 163 | each nonoption \fIargv\fP-element is handled as if it were the argument of |
fea681da MK |
164 | an option with character code 1. (This is used by programs that were |
165 | written to expect options and other \fIargv\fP-elements in any order | |
166 | and that care about the ordering of the two.) | |
167 | The special argument "\-\-" forces an end of option-scanning regardless | |
168 | of the scanning mode. | |
169 | .PP | |
60a90ecd MK |
170 | If |
171 | .BR getopt () | |
172 | does not recognize an option character, it prints an | |
ce2801d0 | 173 | error message to \fIstderr\fP, stores the character in \fIoptopt\fP, and |
f81fb444 | 174 | returns \(aq?\(aq. |
c13182ef | 175 | The calling program may prevent the error message by |
fea681da MK |
176 | setting \fIopterr\fP to 0. |
177 | .PP | |
60a90ecd MK |
178 | If |
179 | .BR getopt () | |
180 | finds an option character in \fIargv\fP that was not | |
fea681da | 181 | included in \fIoptstring\fP, or if it detects a missing option argument, |
0425de01 | 182 | it returns \(aq?\(aq and sets the external variable \fIoptopt\fP to the |
c13182ef MK |
183 | actual option character. |
184 | If the first character | |
f81fb444 | 185 | (following any optional \(aq+\(aq or \(aq\-\(aq described above) |
fea681da | 186 | of \fIoptstring\fP |
f81fb444 | 187 | is a colon (\(aq:\(aq), then |
60a90ecd | 188 | .BR getopt () |
f81fb444 | 189 | returns \(aq:\(aq instead of \(aq?\(aq to |
c13182ef MK |
190 | indicate a missing option argument. |
191 | If an error was detected, and | |
fea681da | 192 | the first character of \fIoptstring\fP is not a colon, and |
c7094399 | 193 | the external variable \fIopterr\fP is nonzero (which is the default), |
60a90ecd MK |
194 | .BR getopt () |
195 | prints an error message. | |
2aeec1f9 | 196 | .SS getopt_long() and getopt_long_only() |
fea681da | 197 | The |
f10e4102 | 198 | .BR getopt_long () |
fea681da | 199 | function works like |
f10e4102 | 200 | .BR getopt () |
c1ed35a7 | 201 | except that it also accepts long options, started with two dashes. |
d0ac4fb3 MK |
202 | (If the program accepts only long options, then |
203 | .I optstring | |
204 | should be specified as an empty string (""), not NULL.) | |
fea681da | 205 | Long option names may be abbreviated if the abbreviation is |
c13182ef MK |
206 | unique or is an exact match for some defined option. |
207 | A long option | |
fea681da MK |
208 | may take a parameter, of the form |
209 | .B \-\-arg=param | |
210 | or | |
211 | .BR "\-\-arg param" . | |
212 | .PP | |
213 | .I longopts | |
214 | is a pointer to the first element of an array of | |
8478ee02 | 215 | .I struct option |
fea681da | 216 | declared in |
8478ee02 | 217 | .I <getopt.h> |
fea681da | 218 | as |
088a639b | 219 | .in +4n |
fea681da MK |
220 | .nf |
221 | .sp | |
fea681da | 222 | struct option { |
cf448976 MK |
223 | const char *name; |
224 | int has_arg; | |
225 | int *flag; | |
226 | int val; | |
fea681da MK |
227 | }; |
228 | .fi | |
cf448976 | 229 | .in |
fea681da MK |
230 | .PP |
231 | The meanings of the different fields are: | |
232 | .TP | |
233 | .I name | |
234 | is the name of the long option. | |
235 | .TP | |
236 | .I has_arg | |
237 | is: | |
f10e4102 MK |
238 | \fBno_argument\fP (or 0) if the option does not take an argument; |
239 | \fBrequired_argument\fP (or 1) if the option requires an argument; or | |
fea681da MK |
240 | \fBoptional_argument\fP (or 2) if the option takes an optional argument. |
241 | .TP | |
242 | .I flag | |
c13182ef MK |
243 | specifies how results are returned for a long option. |
244 | If \fIflag\fP | |
60a90ecd MK |
245 | is NULL, then |
246 | .BR getopt_long () | |
7066ef44 MK |
247 | returns \fIval\fP. |
248 | (For example, the calling program may set \fIval\fP to the equivalent short | |
c13182ef | 249 | option character.) |
60a90ecd MK |
250 | Otherwise, |
251 | .BR getopt_long () | |
252 | returns 0, and | |
fea681da MK |
253 | \fIflag\fP points to a variable which is set to \fIval\fP if the |
254 | option is found, but left unchanged if the option is not found. | |
255 | .TP | |
c13182ef | 256 | \fIval\fP |
fea681da MK |
257 | is the value to return, or to load into the variable pointed |
258 | to by \fIflag\fP. | |
259 | .PP | |
7b01461a | 260 | The last element of the array has to be filled with zeros. |
fea681da | 261 | .PP |
35e21ba7 | 262 | If \fIlongindex\fP is not NULL, it |
fea681da MK |
263 | points to a variable which is set to the index of the long option relative to |
264 | .IR longopts . | |
265 | .PP | |
60a90ecd MK |
266 | .BR getopt_long_only () |
267 | is like | |
268 | .BR getopt_long (), | |
f81fb444 | 269 | but \(aq\-\(aq as well |
f8a07a21 | 270 | as "\-\-" can indicate a long option. |
f81fb444 | 271 | If an option that starts with \(aq\-\(aq |
f8a07a21 | 272 | (not "\-\-") doesn't match a long option, but does match a short option, |
c13182ef | 273 | it is parsed as a short option instead. |
47297adb | 274 | .SH RETURN VALUE |
f10e4102 MK |
275 | If an option was successfully found, then |
276 | .BR getopt () | |
277 | returns the option character. | |
278 | If all command-line options have been parsed, then | |
279 | .BR getopt () | |
280 | returns \-1. | |
281 | If | |
282 | .BR getopt () | |
283 | encounters an option character that was not in | |
284 | .IR optstring , | |
f81fb444 | 285 | then \(aq?\(aq is returned. |
f10e4102 MK |
286 | If |
287 | .BR getopt () | |
288 | encounters an option with a missing argument, | |
289 | then the return value depends on the first character in | |
290 | .IR optstring : | |
f81fb444 | 291 | if it is \(aq:\(aq, then \(aq:\(aq is returned; otherwise \(aq?\(aq is returned. |
fea681da | 292 | .PP |
60a90ecd MK |
293 | .BR getopt_long () |
294 | and | |
295 | .BR getopt_long_only () | |
296 | also return the option | |
c13182ef MK |
297 | character when a short option is recognized. |
298 | For a long option, they | |
299 | return \fIval\fP if \fIflag\fP is NULL, and 0 otherwise. | |
60a90ecd MK |
300 | Error and \-1 returns are the same as for |
301 | .BR getopt (), | |
f81fb444 | 302 | plus \(aq?\(aq for an |
fea681da | 303 | ambiguous match or an extraneous parameter. |
d219a1a3 | 304 | .SH ENVIRONMENT |
fea681da | 305 | .TP |
fea681da | 306 | .B POSIXLY_CORRECT |
24b74457 | 307 | If this is set, then option processing stops as soon as a nonoption |
fea681da MK |
308 | argument is encountered. |
309 | .TP | |
fea681da MK |
310 | .B _<PID>_GNU_nonoption_argv_flags_ |
311 | This variable was used by | |
f19a0f03 | 312 | .BR bash (1) |
5260fe08 | 313 | 2.0 to communicate to glibc which arguments are the results of |
c13182ef | 314 | wildcard expansion and so should not be considered as options. |
d9bfdb9c | 315 | This behavior was removed in |
f19a0f03 | 316 | .BR bash (1) |
5260fe08 | 317 | version 2.01, but the support remains in glibc. |
c7401a75 PH |
318 | .SH ATTRIBUTES |
319 | For an explanation of the terms used in this section, see | |
320 | .BR attributes (7). | |
321 | .TS | |
322 | allbox; | |
323 | lbw24 lb lb | |
324 | l l l. | |
325 | Interface Attribute Value | |
326 | T{ | |
327 | .BR getopt (), | |
328 | .BR getopt_long (), | |
329 | .BR getopt_long_only () | |
5eef415b | 330 | T} Thread safety MT-Unsafe race:getopt env |
c7401a75 | 331 | .TE |
47297adb | 332 | .SH CONFORMING TO |
2b2581ee MK |
333 | .TP |
334 | .BR getopt (): | |
88490b86 | 335 | POSIX.1-2001, POSIX.1-2008, and POSIX.2, |
d9a10d9d MK |
336 | provided the environment variable |
337 | .B POSIXLY_CORRECT | |
338 | is set. | |
1e3ae1b4 MK |
339 | Otherwise, the elements of \fIargv\fP aren't really |
340 | .IR const , | |
341 | because we permute them. | |
342 | We pretend they're | |
343 | .I const | |
344 | in the prototype to be compatible with other systems. | |
ca92ce95 | 345 | |
e94c735e MK |
346 | The use of \(aq+\(aq and \(aq\-\(aq in |
347 | .I optstring | |
348 | is a GNU extension. | |
349 | ||
2b2581ee MK |
350 | On some older implementations, |
351 | .BR getopt () | |
352 | was declared in | |
353 | .IR <stdio.h> . | |
354 | SUSv1 permitted the declaration to appear in either | |
355 | .I <unistd.h> | |
356 | or | |
357 | .IR <stdio.h> . | |
358 | POSIX.1-2001 marked the use of | |
359 | .I <stdio.h> | |
360 | for this purpose as LEGACY. | |
361 | POSIX.1-2001 does not allow the declaration to appear in | |
362 | .IR <stdio.h> . | |
e94c735e MK |
363 | .TP |
364 | .BR getopt_long "() and " getopt_long_only (): | |
365 | These functions are GNU extensions. | |
366 | .SH NOTES | |
367 | A program that scans multiple argument vectors, | |
368 | or rescans the same vector more than once, | |
369 | and wants to make use of GNU extensions such as \(aq+\(aq | |
c2a80b76 | 370 | and \(aq\-\(aq at the start of |
e94c735e MK |
371 | .IR optstring , |
372 | or changes the value of | |
373 | .B POSIXLY_CORRECT | |
374 | between scans, | |
375 | must reinitialize | |
376 | .BR getopt () | |
377 | by resetting | |
378 | .I optind | |
379 | to 0, rather than the traditional value of 1. | |
380 | (Resetting to 0 forces the invocation of an internal initialization | |
381 | routine that rechecks | |
382 | .B POSIXLY_CORRECT | |
383 | and checks for GNU extensions in | |
384 | .IR optstring .) | |
fea681da | 385 | .SH EXAMPLE |
81e10454 | 386 | .SS getopt() |
92e014f6 MK |
387 | The following trivial example program uses |
388 | .BR getopt () | |
c13182ef | 389 | to handle two program options: |
f262c004 | 390 | .IR \-n , |
92e014f6 | 391 | with no associated value; and |
f262c004 | 392 | .IR "\-t val" , |
92e014f6 MK |
393 | which expects an associated value. |
394 | .nf | |
395 | .sp | |
396 | #include <unistd.h> | |
397 | #include <stdlib.h> | |
398 | #include <stdio.h> | |
399 | ||
400 | int | |
401 | main(int argc, char *argv[]) | |
402 | { | |
403 | int flags, opt; | |
404 | int nsecs, tfnd; | |
405 | ||
406 | nsecs = 0; | |
407 | tfnd = 0; | |
408 | flags = 0; | |
29059a65 | 409 | while ((opt = getopt(argc, argv, "nt:")) != \-1) { |
92e014f6 | 410 | switch (opt) { |
f81fb444 | 411 | case \(aqn\(aq: |
92e014f6 MK |
412 | flags = 1; |
413 | break; | |
f81fb444 | 414 | case \(aqt\(aq: |
92e014f6 MK |
415 | nsecs = atoi(optarg); |
416 | tfnd = 1; | |
417 | break; | |
f81fb444 | 418 | default: /* \(aq?\(aq */ |
29059a65 | 419 | fprintf(stderr, "Usage: %s [\-t nsecs] [\-n] name\\n", |
cec29a73 | 420 | argv[0]); |
92e014f6 MK |
421 | exit(EXIT_FAILURE); |
422 | } | |
423 | } | |
424 | ||
26f418da MK |
425 | printf("flags=%d; tfnd=%d; nsecs=%d; optind=%d\\n", |
426 | flags, tfnd, nsecs, optind); | |
92e014f6 MK |
427 | |
428 | if (optind >= argc) { | |
429 | fprintf(stderr, "Expected argument after options\\n"); | |
430 | exit(EXIT_FAILURE); | |
431 | } | |
432 | ||
433 | printf("name argument = %s\\n", argv[optind]); | |
434 | ||
435 | /* Other code omitted */ | |
436 | ||
437 | exit(EXIT_SUCCESS); | |
438 | } | |
439 | .fi | |
81e10454 | 440 | .SS getopt_long() |
fea681da | 441 | The following example program illustrates the use of |
f10e4102 | 442 | .BR getopt_long () |
fea681da MK |
443 | with most of its features. |
444 | .nf | |
445 | .sp | |
446 | #include <stdio.h> /* for printf */ | |
447 | #include <stdlib.h> /* for exit */ | |
448 | #include <getopt.h> | |
449 | ||
450 | int | |
c13182ef | 451 | main(int argc, char **argv) |
41798314 | 452 | { |
fea681da MK |
453 | int c; |
454 | int digit_optind = 0; | |
455 | ||
456 | while (1) { | |
457 | int this_option_optind = optind ? optind : 1; | |
458 | int option_index = 0; | |
459 | static struct option long_options[] = { | |
e5266ff9 BW |
460 | {"add", required_argument, 0, 0 }, |
461 | {"append", no_argument, 0, 0 }, | |
462 | {"delete", required_argument, 0, 0 }, | |
463 | {"verbose", no_argument, 0, 0 }, | |
464 | {"create", required_argument, 0, \(aqc\(aq}, | |
465 | {"file", required_argument, 0, 0 }, | |
466 | {0, 0, 0, 0 } | |
fea681da MK |
467 | }; |
468 | ||
cf0a9ace | 469 | c = getopt_long(argc, argv, "abc:d:012", |
fea681da MK |
470 | long_options, &option_index); |
471 | if (c == \-1) | |
472 | break; | |
473 | ||
474 | switch (c) { | |
475 | case 0: | |
cf0a9ace | 476 | printf("option %s", long_options[option_index].name); |
fea681da | 477 | if (optarg) |
cf0a9ace MK |
478 | printf(" with arg %s", optarg); |
479 | printf("\\n"); | |
fea681da MK |
480 | break; |
481 | ||
f81fb444 MK |
482 | case \(aq0\(aq: |
483 | case \(aq1\(aq: | |
484 | case \(aq2\(aq: | |
fea681da | 485 | if (digit_optind != 0 && digit_optind != this_option_optind) |
29059a65 | 486 | printf("digits occur in two different argv\-elements.\\n"); |
fea681da | 487 | digit_optind = this_option_optind; |
cf0a9ace | 488 | printf("option %c\\n", c); |
fea681da MK |
489 | break; |
490 | ||
f81fb444 | 491 | case \(aqa\(aq: |
cf0a9ace | 492 | printf("option a\\n"); |
fea681da MK |
493 | break; |
494 | ||
f81fb444 | 495 | case \(aqb\(aq: |
cf0a9ace | 496 | printf("option b\\n"); |
fea681da MK |
497 | break; |
498 | ||
f81fb444 MK |
499 | case \(aqc\(aq: |
500 | printf("option c with value \(aq%s\(aq\\n", optarg); | |
fea681da MK |
501 | break; |
502 | ||
f81fb444 MK |
503 | case \(aqd\(aq: |
504 | printf("option d with value \(aq%s\(aq\\n", optarg); | |
fea681da MK |
505 | break; |
506 | ||
f81fb444 | 507 | case \(aq?\(aq: |
fea681da MK |
508 | break; |
509 | ||
510 | default: | |
cf0a9ace | 511 | printf("?? getopt returned character code 0%o ??\\n", c); |
fea681da MK |
512 | } |
513 | } | |
514 | ||
515 | if (optind < argc) { | |
29059a65 | 516 | printf("non\-option ARGV\-elements: "); |
fea681da | 517 | while (optind < argc) |
cf0a9ace MK |
518 | printf("%s ", argv[optind++]); |
519 | printf("\\n"); | |
fea681da MK |
520 | } |
521 | ||
4c44ffe5 | 522 | exit(EXIT_SUCCESS); |
fea681da MK |
523 | } |
524 | .fi | |
47297adb | 525 | .SH SEE ALSO |
35d82b25 | 526 | .BR getopt (1), |
0a4f8b7b | 527 | .BR getsubopt (3) |