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 480c00139e08682fd15d5798d871be4c85111b76..c6e146251801835add4a2c4f36711eb4e162dbcf 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]=='-']==':';