diff --git a/Userland/Libraries/LibC/getopt.cpp b/Userland/Libraries/LibC/getopt.cpp index 6e8d1a09e9..4f9a6bc816 100644 --- a/Userland/Libraries/LibC/getopt.cpp +++ b/Userland/Libraries/LibC/getopt.cpp @@ -33,7 +33,7 @@ int getopt(int argc, char* const* argv, char const* short_options) for (auto i = 1; i < argc; ++i) s_args.append({ argv[i], strlen(argv[i]) }); - if (optind == 0 || optreset == 1) { + if (optind == 1 || optreset == 1) { s_parser.reset_state(); optind = 1; optreset = 0; @@ -75,7 +75,7 @@ int getopt_long(int argc, char* const* argv, char const* short_options, const st }); } - if (optind == 0 || optreset == 1) { + if (optind == 1 || optreset == 1) { s_parser.reset_state(); optind = 1; optreset = 0; diff --git a/Userland/Libraries/LibC/unistd.h b/Userland/Libraries/LibC/unistd.h index 66b9a72132..47e5a2fcdb 100644 --- a/Userland/Libraries/LibC/unistd.h +++ b/Userland/Libraries/LibC/unistd.h @@ -166,8 +166,7 @@ extern int optopt; // Index of the next argument to process upon a getopt*() call. extern int optind; // If set, reset the internal state kept by getopt*(). You may also want to set -// optind to 1 in that case. Alternatively, setting optind to 0 is treated like -// doing both of the above. +// optind to 1 in that case. extern int optreset; // After parsing an option that accept an argument, set to point to the argument // value.