I’m using StringArray::fromTokens() to parse command-line options to my app. I want something like
This is what I have:
This is the strange part. Here’s three instances of command-line input and the contents of cmdparams afterwards.
> software.exe --open=C:\filename_without_spaces.txt --other-parameter
cmdparams[0] = --open=C:\filename_without_spaces.txt
cmdparams[1] = --other-parameter
-------------------------------
> software.exe --open="C:\filename_without_spaces.txt" --other-parameter
cmdparams[0] = --open=C:\filename_without_spaces.txt
cmdparams[1] = --other-parameter
-------------------------------
> software.exe --open="C:\filename with spaces.txt" --other-parameter
cmdparams[0] = "--open=C:\filename with spaces.txt"
cmdparams[1] = --other-parameter
It always keeps the right parameters together, which is good. In the second instance, it gets rid of the quotes, which is okay but a little strange. But in the third instance, it gets rid of the quotes around the filename, and adds them around the whole parameter! Then comparing the first characters to “–open=” fails, and it doesn’t recognize the command-line parameters.
Right now I have the workaround of using cmdparams[0].unquoted(), which works fine. But I was wondering if this was intentional behavior of StringArray::fromTokens() or a bug (there’s nothing about this in the API documentation). Thanks!