aboutsummaryrefslogtreecommitdiff
path: root/cmd-if-shell.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2014-12-15 09:24:15 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2014-12-15 09:24:15 +0000
commitf495b150fa06cf0556159fe15e0dd2e0a09bb445 (patch)
tree7c48105f6febbe65b9cbed3027bffc1b8bc6e0d5 /cmd-if-shell.c
parent3771ab7c67ed002faa980b353bcc858669131b58 (diff)
parentccbe2545d9857e03731eddb9757989b9f52dc785 (diff)
downloadrtmux-f495b150fa06cf0556159fe15e0dd2e0a09bb445.tar.gz
rtmux-f495b150fa06cf0556159fe15e0dd2e0a09bb445.tar.bz2
rtmux-f495b150fa06cf0556159fe15e0dd2e0a09bb445.zip
Merge branch 'master' of ssh://git.code.sf.net/p/tmux/tmux-code
Diffstat (limited to 'cmd-if-shell.c')
-rw-r--r--cmd-if-shell.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/cmd-if-shell.c b/cmd-if-shell.c
index da0220ca..15432919 100644
--- a/cmd-if-shell.c
+++ b/cmd-if-shell.c
@@ -37,8 +37,8 @@ void cmd_if_shell_free(void *);
const struct cmd_entry cmd_if_shell_entry = {
"if-shell", "if",
- "bt:", 2, 3,
- "[-b] " CMD_TARGET_PANE_USAGE " shell-command command [command]",
+ "bFt:", 2, 3,
+ "[-bF] " CMD_TARGET_PANE_USAGE " shell-command command [command]",
0,
cmd_if_shell_exec
};
@@ -56,7 +56,8 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_q *cmdq)
{
struct args *args = self->args;
struct cmd_if_shell_data *cdata;
- char *shellcmd;
+ char *shellcmd, *cmd, *cause;
+ struct cmd_list *cmdlist;
struct client *c;
struct session *s = NULL;
struct winlink *wl = NULL;
@@ -84,6 +85,26 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_q *cmdq)
shellcmd = format_expand(ft, args->argv[0]);
format_free(ft);
+ if (args_has(args, 'F')) {
+ cmd = NULL;
+ if (*shellcmd != '0' && *shellcmd != '\0')
+ cmd = args->argv[1];
+ else if (args->argc == 3)
+ cmd = args->argv[2];
+ if (cmd == NULL)
+ return (CMD_RETURN_NORMAL);
+ if (cmd_string_parse(cmd, &cmdlist, NULL, 0, &cause) != 0) {
+ if (cause != NULL) {
+ cmdq_error(cmdq, "%s", cause);
+ free(cause);
+ }
+ return (CMD_RETURN_ERROR);
+ }
+ cmdq_run(cmdq, cmdlist);
+ cmd_list_free(cmdlist);
+ return (CMD_RETURN_NORMAL);
+ }
+
cdata = xmalloc(sizeof *cdata);
cdata->cmd_if = xstrdup(args->argv[1]);
if (args->argc == 3)