Preserve file and flags.

This commit is contained in:
Nicholas Marriott
2026-06-30 17:37:15 +01:00
parent 08500f844d
commit c92720e3b0
5 changed files with 68 additions and 12 deletions

View File

@@ -58,6 +58,8 @@ struct cmd_run_shell_data {
struct client *client;
char *cmd;
struct cmd_parse_tree *tree;
char *file;
int parse_flags;
char *cwd;
struct cmdq_item *item;
struct session *s;
@@ -114,7 +116,7 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
struct client *tc = cmdq_get_target_client(item);
struct session *s = target->s;
struct window_pane *wp = target->wp;
const char *delay, *cmd;
const char *delay, *cmd, *file;
struct format_tree *ft;
double d;
struct timeval tv;
@@ -153,6 +155,10 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
cmd_run_shell_free(cdata);
return (CMD_RETURN_ERROR);
}
cmd_get_source(self, &file, NULL);
if (file != NULL)
cdata->file = xstrdup(file);
cdata->parse_flags = cmd_get_parse_flags(self);
}
if (args_has(args, 't') && wp != NULL)
@@ -206,6 +212,7 @@ cmd_run_shell_timer(__unused int fd, __unused short events, void* arg)
const char *cmd = cdata->cmd;
struct cmdq_item *item = cdata->item, *new_item;
struct cmdq_state *cs = NULL;
struct cmd_invoke_input input = { 0 };
if (cdata->tree == NULL) {
if (cmd == NULL) {
@@ -232,7 +239,9 @@ cmd_run_shell_timer(__unused int fd, __unused short events, void* arg)
if (item != NULL)
cs = cmdq_get_state(item);
new_item = cmd_invoke_get(cdata->tree, cs, NULL);
input.file = cdata->file;
input.flags = cdata->parse_flags;
new_item = cmd_invoke_get(cdata->tree, cs, &input);
if (item == NULL)
cmdq_append(c, new_item);
else
@@ -305,6 +314,7 @@ cmd_run_shell_free(void *data)
if (cdata->client != NULL)
server_client_unref(cdata->client);
cmd_parse_free(cdata->tree);
free(cdata->file);
free(cdata->cwd);
free(cdata->cmd);
free(cdata);