summaryrefslogtreecommitdiffstats
path: root/cmd-run-shell.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2013-03-24 09:33:35 +0000
committerNicholas Marriott <nicm@openbsd.org>2013-03-24 09:33:35 +0000
commit66edb3392b234ccd9a940039936edb34258c2102 (patch)
tree031db116295f4f8d2069f8cfb96d8851e59f600a /cmd-run-shell.c
parent86adcd4b2666344e9e77fc8f27ab8124557713f2 (diff)
Expand format variables in the run-shell and if-shell shell commands,
from Thiago Padilha.
Diffstat (limited to 'cmd-run-shell.c')
-rw-r--r--cmd-run-shell.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/cmd-run-shell.c b/cmd-run-shell.c
index 0d19a8e6..3942fa11 100644
--- a/cmd-run-shell.c
+++ b/cmd-run-shell.c
@@ -75,14 +75,25 @@ cmd_run_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct args *args = self->args;
struct cmd_run_shell_data *cdata;
- const char *shellcmd = args->argv[0];
+ char *shellcmd;
+ struct session *s;
+ struct winlink *wl;
struct window_pane *wp;
+ struct format_tree *ft;
- if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
+ wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp);
+ if (wl == NULL)
return (CMD_RETURN_ERROR);
+ ft = format_create();
+ format_session(ft, s);
+ format_winlink(ft, s, wl);
+ format_window_pane(ft, wp);
+ shellcmd = format_expand(ft, args->argv[0]);
+ format_free(ft);
+
cdata = xmalloc(sizeof *cdata);
- cdata->cmd = xstrdup(args->argv[0]);
+ cdata->cmd = shellcmd;
cdata->wp_id = wp->id;
cdata->ctx = ctx;