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

Dimitar Zhekov dimitar.zhekov at xxxxx
Wed Apr 1 17:50:11 UTC 2015

On 01.4.2015 г. 04:33, Lex Trotman wrote:
> On 1 April 2015 at 04:45, Dimitar Zhekov<dimitar.zhekov at gmail.com>  wrote:
>> On 31.3.2015 г. 03:16, Lex Trotman wrote:
>> - 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).

Really... with double quotes, very nice for Windows. :)

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

Or remove them if we do minimal native quotation.

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

I should have clarified: if the original command, before any placeholder 
expansion, does not contain any quotes. If there is at least a single 
quote, we assume the user knows what (s)he is doing.

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

Quote it *natively*. That is "name" under Windows (can not contain "), 
and 'name' under Unix, with ' escaped. For file and directory name 
placeholders only. I don't think any child program will want to receive 
file names with spaces split into several arguments.

> Maybe we should throw away running under the shell, who's silly idea
> was it anyway :)

It'll be a good thing to do IMHO, but won't help in this case. We split 
the non-shell commands under Unix with glib's g_shell_parse_argv(), 
which uses the shell syntax. So quoting with 'name' and escaping ' is 
always right.

> [1] think of %f being "fred's data" inside single quotes

'fred'\''s data' (I guess you don't mean " as part of the name, but they 
won't be problematic either)

> [2] think of the %f being "$amounts", that will confuse the shell, and
> will be real fun if amounts is defined :)

'$amounts'. Our current double-quoted placeholders make it "$amounts", 
so the users users of Geany can have fun.

E-gards: Jimmy

More information about the Devel mailing list