g_spawn_win32_helper quoting



Hi,

I have some problems using g_spawn* functions since glib > 2.2.0.
If a parameter of the called application is enclosed in double
quotes, those quotes are escaped with a backslash. This causes
errors, as cmd/command are not able to handle that syntax (same
for other win32 apps). This also applies to single quotes.
Sometimes quotes are required, e.g.
  c:\vim\gvim.exe "file with spc" -c ":set ft=mail"
needs the last part grouped together by quotes, as they all
belong to the "-c" param.

Without the quotes, the last parameters will become
(one argv[] per line):
  -c
  set
  ft
  mail
with quotes:
  -c
  \":set ft=mail\"
with single quotes:
  -c
  ':set
  ft
  mail'

None of them will work, the expected result would be
  -c
  ":set ft=mail"

---- start sample code ----
        // cmd is a user provided command in real life
        cmd = "c:\\vim\\gvim.exe \"file with spc\" -c \":set ft=mail\"";
        child_argv = g_strsplit(cmd, " ", 1024);
        if (g_spawn_async_with_pipes((const gchar *)NULL,
                                     child_argv,
                                     (gchar**)NULL,
                                     G_SPAWN_SEARCH_PATH,
                                     (GSpawnChildSetupFunc)NULL,
                                     (gpointer)NULL,
                                     &pid,
                                     &chld_in[1],
                                     &chld_out[0],
                                     &chld_err[0],
                                     &error) == TRUE)
                { ...whatever... }
---- end sample code ----


I currently use the g_spawn_win32_helper from glib-2.2.0
(official glib-2.2.0-20030112.zip) together with glib-2.2.3
to work around this, but is there a cleaner way?


Btw., as the behaviour now differs between different versions
of g_spawn_win32_helper, including a version resource (e.g.
glib.rc) would be handy.


Best regards,
-- 
Thorsten Maerz          <torte netztorte de>
Sylpheed-claws/Win32:   http://claws-w32.sf.net



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]