aboutsummaryrefslogtreecommitdiff
path: root/cmd-if-shell.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2020-04-13 22:01:30 +0100
committerThomas Adam <thomas@xteddy.org>2020-04-13 22:01:30 +0100
commit2159ff3256df4b823dfaed24e64047249cf079c2 (patch)
tree5652805f202533dd5367bac6659bcf1d558a9348 /cmd-if-shell.c
parentacc00cd13a767067f85ed27d52ad543c9a58869c (diff)
parent187277eaadc4a675659bf7ede88f50bfe6cc7be9 (diff)
downloadrtmux-2159ff3256df4b823dfaed24e64047249cf079c2.tar.gz
rtmux-2159ff3256df4b823dfaed24e64047249cf079c2.tar.bz2
rtmux-2159ff3256df4b823dfaed24e64047249cf079c2.zip
Merge branch 'obsd-master'
Diffstat (limited to 'cmd-if-shell.c')
-rw-r--r--cmd-if-shell.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/cmd-if-shell.c b/cmd-if-shell.c
index ab1b588d..75f462ad 100644
--- a/cmd-if-shell.c
+++ b/cmd-if-shell.c
@@ -65,13 +65,12 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
struct cmd_find_state *target = cmdq_get_target(item);
struct cmdq_state *state = cmdq_get_state(item);
struct cmd_if_shell_data *cdata;
- char *shellcmd, *cmd;
+ char *shellcmd, *cmd, *error;
const char *file;
- struct cmdq_item *new_item;
struct client *c = cmd_find_client(item, NULL, 1);
struct session *s = target->s;
struct cmd_parse_input pi;
- struct cmd_parse_result *pr;
+ enum cmd_parse_status status;
shellcmd = format_single_from_target(item, args->argv[0], c);
if (args_has(args, 'F')) {
@@ -91,19 +90,11 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
pi.c = c;
cmd_find_copy_state(&pi.fs, target);
- pr = cmd_parse_from_string(cmd, &pi);
- switch (pr->status) {
- case CMD_PARSE_EMPTY:
- break;
- case CMD_PARSE_ERROR:
- cmdq_error(item, "%s", pr->error);
- free(pr->error);
+ status = cmd_parse_and_insert(cmd, &pi, item, state, &error);
+ if (status == CMD_PARSE_ERROR) {
+ cmdq_error(item, "%s", error);
+ free(error);
return (CMD_RETURN_ERROR);
- case CMD_PARSE_SUCCESS:
- new_item = cmdq_get_command(pr->cmdlist, state);
- cmdq_insert_after(item, new_item);
- cmd_list_free(pr->cmdlist);
- break;
}
return (CMD_RETURN_NORMAL);
}