From c419594e8aff0fdc17c21e9313169e08f3050a73 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 6 Dec 2009 18:46:57 +0100 Subject: support executing commands both through shell and directly --- uzbl-core.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'uzbl-core.c') diff --git a/uzbl-core.c b/uzbl-core.c index 42e274e..01d0803 100644 --- a/uzbl-core.c +++ b/uzbl-core.c @@ -266,17 +266,24 @@ expand(const char *s, guint recurse) { } else if(recurse != 1 && etype == EXP_EXPR) { - - mycmd = expand(ret, 1); - gchar *quoted = g_shell_quote(mycmd); - gchar *tmp = g_strdup_printf("%s %s", - uzbl.behave.shell_cmd?uzbl.behave.shell_cmd:"/bin/sh -c", - quoted); - g_spawn_command_line_sync(tmp, &cmd_stdout, NULL, NULL, &err); - g_free(mycmd); - g_free(quoted); - g_free(tmp); - + /* execute program directly */ + if(ret[0] == '+') { + mycmd = expand(ret+1, 1); + g_spawn_command_line_sync(mycmd, &cmd_stdout, NULL, NULL, &err); + g_free(mycmd); + } + /* execute program through shell, quote it first */ + else { + mycmd = expand(ret, 1); + gchar *quoted = g_shell_quote(mycmd); + gchar *tmp = g_strdup_printf("%s %s", + uzbl.behave.shell_cmd?uzbl.behave.shell_cmd:"/bin/sh -c", + quoted); + g_spawn_command_line_sync(tmp, &cmd_stdout, NULL, NULL, &err); + g_free(mycmd); + g_free(quoted); + g_free(tmp); + } if (err) { g_printerr("error on running command: %s\n", err->message); g_error_free (err); -- cgit v1.2.3