Pārlūkot izejas kodu

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Marin Hannache 12 gadus atpakaļ
vecāks
revīzija
be90241ec2
1 mainītis faili ar 5 papildinājumiem un 0 dzēšanām
  1. 5
    0
      src/core/getopt.c

+ 5
- 0
src/core/getopt.c Parādīt failu

@@ -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 ) )

Notiek ielāde…
Atcelt
Saglabāt