bug: run-shell -c does not expand #{} formats
I expect run-shell -c "#{pane_current_path}" to start the job in the pane's actual current directory, the same way -c works for new-window/split-window/new-session. Instead the job always starts in $HOME, regardless of the target pane.
mkdir -p /tmp/repro/subdir
tmux -Ltest kill-server
tmux -vv -Ltest -f/dev/null new-session -d -c /tmp/repro/subdir \; \
run-shell -c "#{pane_current_path}" 'pwd > /tmp/repro/out.txt'
cat /tmp/repro/out.txt # prints $HOME, not /tmp/repro/subdir
The debug log shows the format string reaching job_run completely unexpanded:
job_run: cmd=pwd > /tmp/repro/out.txt, cwd=#{pane_current_path}, shell=/bin/sh
chdir("#{pane_current_path}") then fails and falls back to $HOME via find_home(), which is why the symptom looks like "run-shell always launches from home":
https://github.com/tmux/tmux/blob/057d169492a9edbf745283b6cab55e35927164e6/job.c#L142-L144
The -c argument itself is never format-expanded — cmd_run_shell_exec stores it verbatim:
https://github.com/tmux/tmux/blob/057d169492a9edbf745283b6cab55e35927164e6/cmd-run-shell.c#L156-L157
whereas the shell-command argument a few lines above it does go through a format tree.
new-window/split-window/new-session's -c works fine because spawn_pane calls format_single() on it:
https://github.com/tmux/tmux/blob/057d169492a9edbf745283b6cab55e35927164e6/spawn.c#L231-L232
Maybe the fix is something like running args_get(args, 'c') through format_single_from_target() before assigning cdata->cwd, to match what spawn_pane already does.
I checked this is still present in current git master (022b8451), the relevant lines are unchanged from the linked commit.
Required information
- tmux version
3.7c - Platform
Linux x86_64 - Terminal in use:
Gnome Terminal - $TERM inside tmux
tmux-256color - $TERM outside tmux
xterm-256color
Source: tmux/tmux