]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
strutils.c: ignore escape characters while parsing options.
authorWanBingjiang <wanbingjiang@webray.com.cn>
Tue, 22 Apr 2025 10:16:41 +0000 (18:16 +0800)
committerWanBingjiang <wanbingjiang@webray.com.cn>
Tue, 22 Apr 2025 10:16:41 +0000 (18:16 +0800)
lib/strutils.c

index 0cf0da96b6b76e8c8e4667936dcf796dddebb096..8dc7f2513c69391e4bbb6bae9fa104b1c673b62d 100644 (file)
@@ -1235,7 +1235,7 @@ int ul_optstr_next(char **optstr, char **name, size_t *namesz,
                        return -EINVAL;
                if (!start)
                        start = p;              /* beginning of the option item */
-               if (*p == '"')
+               if (*p == '"' && (p == optstr0 || *(p - 1) != '\\'))
                        open_quote ^= 1;        /* reverse the status */
                if (open_quote)
                        continue;               /* still in quoted block */
@@ -1480,7 +1480,8 @@ int main(int argc, char *argv[])
                                "       %1$s --stralnumcmp <str> <str>\n"
                                "       %1$s --cstrcasecmp <str> <str>\n"
                                "       %1$s --normalize <str>\n"
-                               "       %1$s --strto{s,u}{16,32,64} <str>\n",
+                               "       %1$s --strto{s,u}{16,32,64} <str>\n"
+                               "       %1$s --optstr <str>\n",
                                argv[0]);
                exit(EXIT_FAILURE);
        }