changeset 34987:bdf9478e9374

Change "run" command to expand properties. Patch by Jan Christoph Uhde [Jan UhdeJc com], documentation part changed by me.
author reimar
date Sun, 12 Aug 2012 17:57:35 +0000
parents 0eeb639da30e
children bad02d3cc912
files DOCS/tech/slave.txt command.c
diffstat 2 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/DOCS/tech/slave.txt	Sun Aug 12 17:31:47 2012 +0000
+++ b/DOCS/tech/slave.txt	Sun Aug 12 17:57:35 2012 +0000
@@ -508,9 +508,18 @@
     Hides the OSD menu console. Clicking a menu command unhides it. Other
     keybindings act as usual.
 
-run <value>
-    Run <value> as shell command. In OSD menu console mode stdout and stdin
-    are through the video output driver.
+run <string>
+    Run <string> with properties expanded as shell command. In OSD menu
+    console mode stdout and stdin are through the video output driver.
+    Property expansion happens in the same way as for osd_show_property_text.
+    Note: MPlayer will do property expansion on anything of the form
+    ${somevar} before it is passed to the shell.
+    This means that you cannot use this syntax for anything you actually
+    want the shell to handle, though any other form like $somevar will
+    be passed on to and processed by the shell.
+
+    Example:
+    run "echo ${filename} ${stream_pos} >> <path_to_file>"
 
 
 Available properties:
--- a/command.c	Sun Aug 12 17:31:47 2012 +0000
+++ b/command.c	Sun Aug 12 17:57:35 2012 +0000
@@ -3346,7 +3346,11 @@
         case MP_CMD_RUN:
 #ifndef __MINGW32__
             if (!fork()) {
-                execl("/bin/sh", "sh", "-c", cmd->args[0].v.s, NULL);
+                char *exp_cmd = property_expand_string(mpctx, cmd->args[0].v.s);
+                if (exp_cmd) {
+                    execl("/bin/sh", "sh", "-c", exp_cmd, NULL);
+                    free(exp_cmd);
+                }
                 exit(0);
             }
 #endif