cmd-run-shell: expand formats in -c start-directory

-c was taken as a literal string, so run-shell -c '#{pane_current_path}'
tried to chdir into that literal text instead of the target pane's
directory, silently falling back to the server's own cwd. Expand it
through a format tree built from the command's target the same way the
shell-command argument already is.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Michael Grant
2026-09-20 22:38:33 +01:00
parent dc853be713
commit e963101c03

View File

@@ -163,9 +163,11 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
}
if (cdata->client != NULL)
cdata->client->references++;
if (args_has(args, 'c'))
cdata->cwd = xstrdup(args_get(args, 'c'));
else
if (args_has(args, 'c')) {
ft = format_create_from_target(item);
cdata->cwd = format_expand(ft, args_get(args, 'c'));
format_free(ft);
} else
cdata->cwd = xstrdup(server_client_get_cwd(c, s));
if (args_has(args, 'E'))