[Geany-Devel] Spawn module API

Dimitar Zhekov dimitar.zhekov at xxxxx
Thu Jun 25 17:13:37 UTC 2015

On 24.6.2015 г. 03:12, Lex Trotman wrote:
> On 24 June 2015 at 10:06, Colomban Wendling<lists.ban at herbesfolles.org>  wrote:
>> Le 24/06/2015 01:57, Lex Trotman a écrit :
>>> Colomban,
>>> Correct me if I'm wrong, but despite my loudly voiced misgivings :)
>>> doesn't the spawn_* series do command quoting and g_spawn* not?

No. It uses quoting only internally, (a) when creating a Windows command 
line from argv, for obvious reasons, and (b) if your Windows CL program 
name contains spaces, to make sure that you won't run "C:\Program.exe" 
or "C:\Program Files\Foo.exe" if your "C:\Program Files\Foo\Bar.exe" 
does not exist. Yes, CreateProcess() will really try them, if you miss 
the quotes by mistake.

[g_]spawn*() via argv produce identical results.

>> Well, those support an additional "command" parameter that indeed is
>> read in a platform-dependent manner.  (this was a discussion point and
>> ended like this).
>> They however also support argvs just fine, so you can use those too and
>> they would work the same.  With this, you can also imagine using
>> g_shell_parse_argv() on all platforms if you like, just like you would
>> do with g_spawn().
> Then Geany should be changed to do that too, for all commands (IIRC
> build commands already do it).

Unless one is using \ as escape character or ' for quoting under 
Windows, the commands will work. The default filetypes always contain 
"%x" and never '%x', so they will work.

> Note by "user" I mean the end user, not the plugin programmer.  Having
> the end user need to know if they should quote commands or not is bad
> (tm).  If that is already the case then it should be fixed.

They only need to quote a %x which may contain spaces, as usual, using 
double quotes, as in the default filetypes. The documentation examples 
also show double quotes, and unless I'm not missing something, we don't 
guarantee that \ and ' will work under Windows like in Unix.

The new spawn is more Windows friendly, as it'll never treat the Windows 
directory separator \ as an escape character, and I think that will 
benefit the end users. The forward slashes will work as well (they work 
since MS-DOS 5.0).

E-gards: Jimmy

More information about the Devel mailing list