Skip to content

parseopt not escaping quotes #4620

@Arnaz87

Description

@Arnaz87

When I call a Nim program like this: ./main -i "a\"b\"c" and use the parseopt module to parse the arguments, instead of getting the string a"b"c, I get abc, and if I use spaces,
instead of a " b " c, I get a, b and c.

The problem is in /lib/pure/parseopt.nim in parseWord, at the line 45. The procedure is not considering any escape sequence starting with \, it just keeps going until it finds another ", even if it's escaped.

After looking a little more, I found that using parseopt2 solves the problem, by using a list of arguments instead of a concatenated command, but then why is the broken version still in the standard library and is not deprecated?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions