[Geany-Devel] Placeholder replacement in (build) commands

Dimitar Zhekov dimitar.zhekov at xxxxx
Tue Mar 31 17:45:19 UTC 2015


On 31.3.2015 г. 03:16, Lex Trotman wrote:
> On 31 March 2015 at 11:14, Colomban Wendling<lists.ban at 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.

--

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. :)

- The quotes are different under Unix/Win~1: single vs. double.

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.

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.

--
E-gards: Jimmy


More information about the Devel mailing list