Skip to content

Commit

Permalink
Properly escape working directory in run script using g_shell_quote()
Browse files Browse the repository at this point in the history
The g_strescape() function escapes non-ASCII characters so that bash
doesn't understand them.
  • Loading branch information
techee committed Jul 3, 2015
1 parent 89f7a2e commit 41184e4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/build.c
Original file line number Diff line number Diff line change
Expand Up @@ -1088,9 +1088,9 @@ static gchar *build_create_shellscript(const gchar *working_dir, const gchar *cm
str = g_strdup_printf("cd \"%s\"\n\n%s\n\n%s\ndel \"%%0\"\n\npause\n", working_dir, expanded_cmd, (autoclose) ? "" : "pause");
g_free(expanded_cmd);
#else
escaped_dir = g_strescape(working_dir, NULL);
escaped_dir = g_shell_quote(working_dir);
str = g_strdup_printf(
"#!/bin/sh\n\nrm $0\n\ncd \'%s\'\n\n%s\n\necho \"\n\n------------------\n(program exited with code: $?)\" \
"#!/bin/sh\n\nrm $0\n\ncd %s\n\n%s\n\necho \"\n\n------------------\n(program exited with code: $?)\" \
\n\n%s\n", escaped_dir, cmd, (autoclose) ? "" :
"\necho \"Press return to continue\"\n#to be more compatible with shells like "
"dash\ndummy_var=\"\"\nread dummy_var");
Expand Down

0 comments on commit 41184e4

Please sign in to comment.