Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'win32-quote-spawn-args'

Closes bug #943 and PR #180.
  • Loading branch information...
commit 26d2ef8d99c6c66796d7ab8b4a09aa230c9905ac 2 parents 7d76063 + 044120e
@b4n b4n authored
Showing with 9 additions and 2 deletions.
  1. +9 −2 src/win32.c
View
11 src/win32.c
@@ -1038,6 +1038,7 @@ gboolean win32_spawn(const gchar *dir, gchar **argv, gchar **env, GSpawnFlags fl
gchar *tmp_file = create_temp_file();
gchar *tmp_errfile = create_temp_file();
gchar *command;
+ gchar *locale_command;
if (env != NULL)
{
@@ -1050,10 +1051,15 @@ gboolean win32_spawn(const gchar *dir, gchar **argv, gchar **env, GSpawnFlags fl
return FALSE;
}
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));
+ 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);
- ret = system(command);
+ errno = 0;
+ ret = system(locale_command);
/* the command can return -1 as an exit code, so check errno also */
fail = ret == -1 && errno;
if (!fail)
@@ -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_free(command);
+ g_free(locale_command);
g_unlink(tmp_file);
g_free(tmp_file);
g_unlink(tmp_errfile);
Please sign in to comment.
Something went wrong with that request. Please try again.