I need to parse a command line string in to the argv format so I can pass it in to execvpe. Basically a linux equivilant to CommandLineToArgvW() from Windows. Is there any function or library I could call to do this? Or do I have to write my own parser? (I was hoping I could steal from BASH if I needed to do this since my program is GPL…)
Example:
I have three variables:
const char* file = "someapplication";
const char* parameters = "param1 -option1 param2";
const char* environment[] = { "Something=something", NULL };
and I want to pass it to execvpe:
execvpe(file, /* parsed parameters */, environment);
PS: I do not want filename expansion but I want quoting and escaping
I used the link given by rve in the comments (http://bbgen.net/blog/2011/06/string-to-argc-argv) and that solved my problem. Upvote his comment, not my answer!