version 1.76, 2021/08/21 10:22:39 |
version 1.77, 2021/08/23 12:33:55 |
|
|
struct cmd_run_shell_data { |
struct cmd_run_shell_data { |
struct client *client; |
struct client *client; |
char *cmd; |
char *cmd; |
int shell; |
struct cmd_list *cmdlist; |
char *cwd; |
char *cwd; |
struct cmdq_item *item; |
struct cmdq_item *item; |
struct session *s; |
struct session *s; |
int wp_id; |
int wp_id; |
struct event timer; |
struct event timer; |
int flags; |
int flags; |
struct cmd_parse_input pi; |
|
}; |
}; |
|
|
static void |
static void |
|
|
struct client *tc = cmdq_get_target_client(item); |
struct client *tc = cmdq_get_target_client(item); |
struct session *s = target->s; |
struct session *s = target->s; |
struct window_pane *wp = target->wp; |
struct window_pane *wp = target->wp; |
const char *delay; |
const char *delay, *cmd; |
double d; |
double d; |
struct timeval tv; |
struct timeval tv; |
char *end; |
char *end; |
const char *cmd = args_string(args, 0); |
|
int wait = !args_has(args, 'b'); |
int wait = !args_has(args, 'b'); |
|
|
if ((delay = args_get(args, 'd')) != NULL) { |
if ((delay = args_get(args, 'd')) != NULL) { |
|
|
return (CMD_RETURN_NORMAL); |
return (CMD_RETURN_NORMAL); |
|
|
cdata = xcalloc(1, sizeof *cdata); |
cdata = xcalloc(1, sizeof *cdata); |
if (cmd != NULL) |
if (!args_has(args, 'C')) { |
cdata->cmd = format_single_from_target(item, cmd); |
cmd = args_string(args, 0); |
|
if (cmd != NULL) |
cdata->shell = !args_has(args, 'C'); |
cdata->cmd = format_single_from_target(item, cmd); |
if (!cdata->shell) { |
} else { |
cmd_get_source(self, &cdata->pi.file, &cdata->pi.line); |
cdata->cmdlist = args_make_commands_now(self, item, 0); |
if (wait) |
if (cdata->cmdlist == NULL) |
cdata->pi.item = item; |
return (CMD_RETURN_ERROR); |
cdata->pi.c = tc; |
|
cmd_find_copy_state(&cdata->pi.fs, target); |
|
} |
} |
|
|
if (args_has(args, 't') && wp != NULL) |
if (args_has(args, 't') && wp != NULL) |
|
|
struct cmd_run_shell_data *cdata = arg; |
struct cmd_run_shell_data *cdata = arg; |
struct client *c = cdata->client; |
struct client *c = cdata->client; |
const char *cmd = cdata->cmd; |
const char *cmd = cdata->cmd; |
char *error; |
struct cmdq_item *item = cdata->item, *new_item; |
struct cmdq_item *item = cdata->item; |
|
enum cmd_parse_status status; |
|
|
|
if (cmd != NULL && cdata->shell) { |
if (cdata->cmdlist == NULL && cmd != NULL) { |
if (job_run(cmd, 0, NULL, cdata->s, cdata->cwd, NULL, |
if (job_run(cmd, 0, NULL, cdata->s, cdata->cwd, NULL, |
cmd_run_shell_callback, cmd_run_shell_free, cdata, |
cmd_run_shell_callback, cmd_run_shell_free, cdata, |
cdata->flags, -1, -1) == NULL) |
cdata->flags, -1, -1) == NULL) |
|
|
return; |
return; |
} |
} |
|
|
if (cmd != NULL) { |
if (cdata->cmdlist != NULL) { |
if (item != NULL) { |
if (item == NULL) { |
status = cmd_parse_and_insert(cmd, &cdata->pi, item, |
new_item = cmdq_get_command(cdata->cmdlist, NULL); |
cmdq_get_state(item), &error); |
cmdq_append(c, new_item); |
} else { |
} else { |
status = cmd_parse_and_append(cmd, &cdata->pi, c, NULL, |
new_item = cmdq_get_command(cdata->cmdlist, |
&error); |
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) |
if (cdata->item != NULL) |
|
|
session_remove_ref(cdata->s, __func__); |
session_remove_ref(cdata->s, __func__); |
if (cdata->client != NULL) |
if (cdata->client != NULL) |
server_client_unref(cdata->client); |
server_client_unref(cdata->client); |
|
if (cdata->cmdlist != NULL) |
|
cmd_list_free(cdata->cmdlist); |
free(cdata->cwd); |
free(cdata->cwd); |
free(cdata->cmd); |
free(cdata->cmd); |
free(cdata); |
free(cdata); |