aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README13
-rw-r--r--examples/config/uzbl/config2
-rw-r--r--uzbl-core.c29
3 files changed, 30 insertions, 14 deletions
diff --git a/README b/README
index 23b0f4e..1ac42a8 100644
--- a/README
+++ b/README
@@ -291,12 +291,21 @@ The above example demonstrates two things:
Command substitution will launch any commands and substitute the call with the return value of the command.
+There are two methods:
-Uzbl will substitute any commands enclosed within @( )@:
+ * through a shell: enclose commands with @( )@ (quotes escaping is handled by uzbl):
print Command substitution: @(uname -a)@
-You can access any uzbl variable from within a command substitution:
+This method allows you to use posix shell syntax in your commands
+
+ * directly:
+
+ print Command substitution: @(+uname -a)@
+
+This example will execute uname directly
+
+Note that you can access any uzbl variable from within a command substitution:
print @(echo -n 'Accessing the show_status var from an external script, value: @show_status')@
diff --git a/examples/config/uzbl/config b/examples/config/uzbl/config
index 5585195..94b1e73 100644
--- a/examples/config/uzbl/config
+++ b/examples/config/uzbl/config
@@ -108,7 +108,7 @@ set status_format = <span font_family="monospace">@mode_section @keycmd_sect
# === Core settings ==========================================================
-set useragent = Uzbl (Webkit @WEBKIT_MAJOR.@WEBKIT_MINOR.@WEBKIT_MICRO) (@(uname -o)@ @(uname -m)@ [@ARCH_UZBL]) (Commit @COMMIT)
+set useragent = Uzbl (Webkit @WEBKIT_MAJOR.@WEBKIT_MINOR.@WEBKIT_MICRO) (@(+uname -o)@ @(+uname -m)@ [@ARCH_UZBL]) (Commit @COMMIT)
set fifo_dir = /tmp
set socket_dir = /tmp
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);