diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2013-02-23 19:24:42 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2013-02-23 19:24:42 +0000 |
commit | 497b27dafb7f531db3b82d6bf061279c599e69ae (patch) | |
tree | df7c47e248e38e036a32d1c2381292cea17d6f91 /cmd-run-shell.c | |
parent | 357da035b9d052b4cba8db806c6237272ade6673 (diff) | |
download | rtmux-497b27dafb7f531db3b82d6bf061279c599e69ae.tar.gz rtmux-497b27dafb7f531db3b82d6bf061279c599e69ae.tar.bz2 rtmux-497b27dafb7f531db3b82d6bf061279c599e69ae.zip |
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.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/cmd-run-shell.c b/cmd-run-shell.c index 9b4c006a..72907937 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]; + const 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; |