getopt on Windows doesn't work correctly with -- args
| Bugzilla Link | 22968 |
| Resolution | INVALID |
| Resolved on | Mar 25, 2015 17:55 |
| Version | unspecified |
| OS | Windows NT |
| Reporter | LLVM Bugzilla Contributor |
Extended Description
Windows provides its own getopt implementation. I don't know the complete details of how getopt it supposed to work but lldb when running a command alias appears to insert a -- argument separator. For example, the "run" command is an alias for "process launch -c
You can see this happening by putting a breakpoint inside of Args::ParseOptions, and stepping over the call to OptionParser::Parse(). It returns -1 even though it should be returning 115 (the optval for the -s option)
Per discussion on lldb-dev, this appears to be working as intended.
The lldb's run alias is intended for compatibility with the gdb version.
It seems this behavior matches the documentation for getopt:
"The special argument "--" forces an end of option-scanning regardless of the scanning mode." [http://man7.org/linux/man-pages/man3/getopt.3.html]
I'll step through your example to see if I can spot the difference in how the command is interpreted on Windows v. non-Windows.
assigned to @amccarth-google