Browse Source

[getopt] Accept "--" as an end-of-options marker

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Marin Hannache 13 years ago
parent
commit
be90241ec2
1 changed files with 5 additions and 0 deletions
  1. 5
    0
      src/core/getopt.c

+ 5
- 0
src/core/getopt.c View File

@@ -239,6 +239,11 @@ int getopt_long ( int argc, char * const argv[], const char *optstring,
239 239
 
240 240
 	/* Check for long options */
241 241
 	if ( *(opttext++) == '-' ) {
242
+		/* "--" indicates end of options */
243
+		if ( *opttext == '\0' ) {
244
+			optind++;
245
+			return -1;
246
+		}
242 247
 		for ( longopt = longopts ; longopt->name ; longopt++ ) {
243 248
 			if ( ! match_long_option ( argc, argv, opttext,
244 249
 						   longopt, &option ) )

Loading…
Cancel
Save