Skip to content

Commit

Permalink
Merge branch 'win32-quote-spawn-args'
Browse files Browse the repository at this point in the history
Closes bug #943 and PR #180.
  • Loading branch information
b4n committed Feb 19, 2014
2 parents 7d76063 + 044120e commit 26d2ef8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/win32.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1038,6 +1038,7 @@ gboolean win32_spawn(const gchar *dir, gchar **argv, gchar **env, GSpawnFlags fl
gchar *tmp_file = create_temp_file(); gchar *tmp_file = create_temp_file();
gchar *tmp_errfile = create_temp_file(); gchar *tmp_errfile = create_temp_file();
gchar *command; gchar *command;
gchar *locale_command;


if (env != NULL) if (env != NULL)
{ {
Expand All @@ -1050,10 +1051,15 @@ gboolean win32_spawn(const gchar *dir, gchar **argv, gchar **env, GSpawnFlags fl
return FALSE; return FALSE;
} }
command = g_strjoinv(" ", argv); command = g_strjoinv(" ", argv);
SETPTR(command, g_strdup_printf("%s >%s 2>%s", SETPTR(command, g_strdup_printf("cmd.exe /S /C \"%s >%s 2>%s\"",
command, tmp_file, tmp_errfile)); command, tmp_file, tmp_errfile));
locale_command = g_locale_from_utf8(command, -1, NULL, NULL, NULL);
if (! locale_command)
locale_command = g_strdup(command);
geany_debug("WIN32: actually running command:\n%s", command);
g_chdir(dir); g_chdir(dir);
ret = system(command); errno = 0;
ret = system(locale_command);
/* the command can return -1 as an exit code, so check errno also */ /* the command can return -1 as an exit code, so check errno also */
fail = ret == -1 && errno; fail = ret == -1 && errno;
if (!fail) if (!fail)
Expand All @@ -1067,6 +1073,7 @@ gboolean win32_spawn(const gchar *dir, gchar **argv, gchar **env, GSpawnFlags fl
g_set_error_literal(error, G_SPAWN_ERROR, errno, g_strerror(errno)); g_set_error_literal(error, G_SPAWN_ERROR, errno, g_strerror(errno));


g_free(command); g_free(command);
g_free(locale_command);
g_unlink(tmp_file); g_unlink(tmp_file);
g_free(tmp_file); g_free(tmp_file);
g_unlink(tmp_errfile); g_unlink(tmp_errfile);
Expand Down

0 comments on commit 26d2ef8

Please sign in to comment.