Closed PMunch closed 7 years ago
Hm actually while thinking about it, the run_command should be rewritten to support quoted arguments, because even user can use quotes in the command - if he types the command instead of clicking on an icon.
Yeah, the execve procedure doesn't really work here since it requires the arguments to be split which would require unnecessary parsing of the Exec field. So we should look for something that can take an arbitrary command, but still replace the process.
Another thing to take into account is environment variables. A .desktop file is fine with "MYVARIABLE=hello program --option".
I think we can ignore this :)
Ignore what? The entire issue? What about something like:
void run_command(char * cmd_orig){
char *array[4] = {0};
array[0] = "sh";
array[1] = "-c";
array[2] = cmd_orig;
int err = execvp(array[0], array);
}
I'm not sure if I want to run shell on each exec. There may be users who do not have sh, rarely.
I think better would be to detect double-quotes in the splitted arguments and if found, join back those arguments which have them, cutting the quotes away.
I really appreciate your effort, thank you for helping with this, because without you, there would be no update whatsoever, I almost forgot about this project at all :)
Hmm, but that won't work with environment variables, or things like $(). I think there are just too many things that might appear in a Exec statement to be run without actually passing it to a shell, or implementing parsing equivalent to what a shell would do. Maybe we could check if the command starts with "xlunch " and then run exec, otherwise run system? Or better yet have a special way to flag an xlunch command in the conf format.
I have actually thought about creating a launcher like this on my own so I really enjoy working on it. The simplicity and customisability is really nice as well!
The tokenize and run with
execvp
approach didn't work correctly with queries using quotes as the arguments would be split across multiple ones. This moves the removal of the % fields to the genconf script and simply runs the command found blindly from the C code.