=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-run-shell.c,v retrieving revision 1.76 retrieving revision 1.77 diff -u -r1.76 -r1.77 --- src/usr.bin/tmux/cmd-run-shell.c 2021/08/21 10:22:39 1.76 +++ src/usr.bin/tmux/cmd-run-shell.c 2021/08/23 12:33:55 1.77 @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-run-shell.c,v 1.76 2021/08/21 10:22:39 nicm Exp $ */ +/* $OpenBSD: cmd-run-shell.c,v 1.77 2021/08/23 12:33:55 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha @@ -53,14 +53,13 @@ struct cmd_run_shell_data { struct client *client; char *cmd; - int shell; + struct cmd_list *cmdlist; char *cwd; struct cmdq_item *item; struct session *s; int wp_id; struct event timer; int flags; - struct cmd_parse_input pi; }; static void @@ -100,11 +99,10 @@ struct client *tc = cmdq_get_target_client(item); struct session *s = target->s; struct window_pane *wp = target->wp; - const char *delay; + const char *delay, *cmd; double d; struct timeval tv; char *end; - const char *cmd = args_string(args, 0); int wait = !args_has(args, 'b'); if ((delay = args_get(args, 'd')) != NULL) { @@ -117,16 +115,14 @@ return (CMD_RETURN_NORMAL); cdata = xcalloc(1, sizeof *cdata); - if (cmd != NULL) - cdata->cmd = format_single_from_target(item, cmd); - - cdata->shell = !args_has(args, 'C'); - if (!cdata->shell) { - cmd_get_source(self, &cdata->pi.file, &cdata->pi.line); - if (wait) - cdata->pi.item = item; - cdata->pi.c = tc; - cmd_find_copy_state(&cdata->pi.fs, target); + if (!args_has(args, 'C')) { + cmd = args_string(args, 0); + if (cmd != NULL) + cdata->cmd = format_single_from_target(item, cmd); + } else { + cdata->cmdlist = args_make_commands_now(self, item, 0); + if (cdata->cmdlist == NULL) + return (CMD_RETURN_ERROR); } if (args_has(args, 't') && wp != NULL) @@ -170,11 +166,9 @@ struct cmd_run_shell_data *cdata = arg; struct client *c = cdata->client; const char *cmd = cdata->cmd; - char *error; - struct cmdq_item *item = cdata->item; - enum cmd_parse_status status; + struct cmdq_item *item = cdata->item, *new_item; - if (cmd != NULL && cdata->shell) { + if (cdata->cmdlist == NULL && cmd != NULL) { if (job_run(cmd, 0, NULL, cdata->s, cdata->cwd, NULL, cmd_run_shell_callback, cmd_run_shell_free, cdata, cdata->flags, -1, -1) == NULL) @@ -182,22 +176,15 @@ return; } - if (cmd != NULL) { - if (item != NULL) { - status = cmd_parse_and_insert(cmd, &cdata->pi, item, - cmdq_get_state(item), &error); + if (cdata->cmdlist != NULL) { + if (item == NULL) { + new_item = cmdq_get_command(cdata->cmdlist, NULL); + cmdq_append(c, new_item); } else { - status = cmd_parse_and_append(cmd, &cdata->pi, c, NULL, - &error); + new_item = cmdq_get_command(cdata->cmdlist, + cmdq_get_state(item)); + cmdq_insert_after(item, new_item); } - if (status == CMD_PARSE_ERROR) { - if (cdata->item == NULL) { - *error = toupper((u_char)*error); - status_message_set(c, -1, 1, 0, "%s", error); - } else - cmdq_error(cdata->item, "%s", error); - free(error); - } } if (cdata->item != NULL) @@ -265,6 +252,8 @@ session_remove_ref(cdata->s, __func__); if (cdata->client != NULL) server_client_unref(cdata->client); + if (cdata->cmdlist != NULL) + cmd_list_free(cdata->cmdlist); free(cdata->cwd); free(cdata->cmd); free(cdata);