fix getopt_long_only misinterpreting "--" as an option
authorRich Felker <dalias@aerifal.cx>
Thu, 20 Oct 2016 16:13:33 +0000 (12:13 -0400)
committerRich Felker <dalias@aerifal.cx>
Thu, 20 Oct 2016 16:13:33 +0000 (12:13 -0400)
src/misc/getopt_long.c

index 480c001..c6e1462 100644 (file)
@@ -53,7 +53,7 @@ static int __getopt_long_core(int argc, char *const *argv, const char *optstring
 {
        optarg = 0;
        if (longopts && argv[optind][0] == '-' &&
-               ((longonly && argv[optind][1]) ||
+               ((longonly && argv[optind][1] && argv[optind][1] != '-') ||
                 (argv[optind][1] == '-' && argv[optind][2])))
        {
                int colon = optstring[optstring[0]=='+'||optstring[0]=='-']==':';