aboutsummaryrefslogtreecommitdiffhomepage
path: root/uzbl-core.c
diff options
context:
space:
mode:
authorGravatar Dieter Plaetinck <dieter@plaetinck.be>2009-12-06 18:46:57 +0100
committerGravatar Dieter Plaetinck <dieter@plaetinck.be>2009-12-06 18:46:57 +0100
commitc419594e8aff0fdc17c21e9313169e08f3050a73 (patch)
tree32504f7c2f5efff1c7f883437fa66282499e17b9 /uzbl-core.c
parentc150136f5b772c35a633afadecf6e3e491ff4ae4 (diff)
support executing commands both through shell and directly
Diffstat (limited to 'uzbl-core.c')
-rw-r--r--uzbl-core.c29
1 files changed, 18 insertions, 11 deletions
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);