On 1 April 2015 at 04:45, Dimitar Zhekov <dimitar.zhe...@gmail.com> wrote: > On 31.3.2015 г. 03:16, Lex Trotman wrote: >> >> On 31 March 2015 at 11:14, Colomban Wendling<lists....@herbesfolles.org> >> wrote: >>> >>> Le 31/03/2015 02:10, Lex Trotman a écrit : >>>> >>>> […] >>>> >>>> Perhaps we should be more explicit in the manual that on *ix build >>>> commands are run in the shell and the user is responsible for either >>>> quoting the substitutions correctly, […] >>> >>> >>> The user currently *cannot* do it "correctly" so it works with any >>> possible replacement, that's actually the problem :] >> >> >> See the second part of the sentence which you elided :-D > > > There is 1 case where the user can't do it correctly: Context Action. > > if (sci_has_selection(doc->editor->sci)) > word = sci_get_selection_contents(doc->editor->sci); > ... > utils_str_replace_all(&command, "%s", word); > spawn_async(... command, ...) > > This can be fixed by removing the %s specified and passing the text as an > argv after the command (the now spawn allows that), with the slight > disadvantage that the selection will always be at the end.
Thats a nice way of making it content independent, but at the cost of allways being at the end and being unable to append/prepend anything to the replacement text. This means that for example adding an extension to a filename extracted from the selection would be impossible. I don't use context actions much, so I can't say how common it would be. > > -- > > In all other cases, except if somebody uses a file or directory name with ' > under Unix for build or printing, the right thing *can* be done by quoting. > But: > > - In all default Geany commands, the placeholders are unquoted, meaning that > any file name with space(s) currently breaks. Shame on us. :) Well some of the default commands are double quoted, but not all IIRC (filetypes.c uses all double quotes for eg). > > - The quotes are different under Unix/Win~1: single vs. double. So in fact we should have two sets of filetype files, one for linstalls and one for winstalls with different quotes on their commands. > > I think there is an absolute minimum we can do about it: quote the > file/directory name placeholders natively, but if, and only if, the entire > command does not contain any single or double quotes. I don't see a way this > can fail, but maybe elextr can prove me wrong. Only for the commands run under the shell, if you mean "no quote character in the command *and* all the replacement texts"[1] then it would work on Linux but that makes its behaviour depend on the command text and the replacement text so I forsee much confusion. Better to be consistent. And if we use double quotes on Linux, then $ and ` (at least) will have special powers[2] which you may not want in a filename, but may want elsewhere. So again we don't know if we should escape the special chars or not. > > Of course, that's not perfect by any means. But if it'll unquestionably > improve the most realistic scenarios (file / directory names with spaces), > with a very small effort, I think it's worth. I think its still "got too many flies on it" as we say here :) Maybe we should throw away running under the shell, who's silly idea was it anyway :) Cheers Lex > > -- > E-gards: Jimmy > [1] think of %f being "fred's data" inside single quotes [2] think of the %f being "$amounts", that will confuse the shell, and will be real fun if amounts is defined :) _______________________________________________ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel