Remove unneeded SHELL_CMD.
authorDaniel Carl <danielcarl@gmx.de>
Wed, 4 Jun 2014 22:03:22 +0000 (00:03 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Wed, 4 Jun 2014 22:04:36 +0000 (00:04 +0200)
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.

src/config.def.h
src/ex.c

index 4440a99..b3849b1 100644 (file)
@@ -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 */
index 5ad6d42..e435f09 100644 (file)
--- 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;
 }