From: Daniel Carl Date: Wed, 4 Jun 2014 22:03:22 +0000 (+0200) Subject: Remove unneeded SHELL_CMD. X-Git-Url: https://git.owens.tech/projects.html/projects.html/git?a=commitdiff_plain;h=ce718c55c61ffea9e1c97f5a34fae2868ba35bcd;p=vimb.git Remove unneeded SHELL_CMD. The g_spawn_command_line_async starts already a shell for us, so there is no need to start a subshell from there. This fixes also some wired quoting issues that appeared if there where single quotes in the given command string to avoid shell expansion. In this case the variables where expanded because of the quoting issue. --- diff --git a/src/config.def.h b/src/config.def.h index 4440a99..b3849b1 100644 --- a/src/config.def.h +++ b/src/config.def.h @@ -74,7 +74,4 @@ #define PROGRESS_BAR_LEN 20 #endif -/* template to run shell command for vimb command :shellcmd */ -#define SHELL_CMD "/bin/sh -c '%s'" - #endif /* end of include guard: _CONFIG_H */ diff --git a/src/ex.c b/src/ex.c index 5ad6d42..e435f09 100644 --- a/src/ex.c +++ b/src/ex.c @@ -866,7 +866,7 @@ static gboolean ex_set(const ExArg *arg) static gboolean ex_shellcmd(const ExArg *arg) { int status; - char *cmd, *stdOut = NULL, *stdErr = NULL; + char *stdOut = NULL, *stdErr = NULL; gboolean success; GError *error = NULL; @@ -874,9 +874,8 @@ static gboolean ex_shellcmd(const ExArg *arg) return false; } - cmd = g_strdup_printf(SHELL_CMD, arg->rhs->str); if (arg->bang) { - if (!g_spawn_command_line_async(cmd, &error)) { + if (!g_spawn_command_line_async(arg->rhs->str, &error)) { g_warning("Can't run '%s': %s", arg->rhs->str, error->message); g_clear_error(&error); success = false; @@ -884,7 +883,7 @@ static gboolean ex_shellcmd(const ExArg *arg) success = true; } } else { - if (!g_spawn_command_line_sync(cmd, &stdOut, &stdErr, &status, &error)) { + if (!g_spawn_command_line_sync(arg->rhs->str, &stdOut, &stdErr, &status, &error)) { g_warning("Can't run '%s': %s", arg->rhs->str, error->message); g_clear_error(&error); success = false; @@ -901,7 +900,6 @@ static gboolean ex_shellcmd(const ExArg *arg) } } - g_free(cmd); return success; }