Skip to content

fix(remote): run the pane wrapper under env so Ghostty's exec cannot drop it - #654

Merged
umputun merged 1 commit into
umputun:masterfrom
wildsurfer:remote-wrapper-env
Sep 25, 2026
Merged

umputun merged 1 commit into
umputun:masterfrom
wildsurfer:remote-wrapper-env

Conversation

@wildsurfer

@wildsurfer wildsurfer commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

The pane command for a remote session is ssh … zmx attach …; status=$?; printf '<disconnected line>'; exit "$status". libghostty runs a surface command as bash -c "exec -l <command>", so bash replaces itself with ssh on the first word and nothing after it runs. The result on master: when ssh exits, the pane shows nothing. The line agterm: <session> (<pane>) on <host> disconnected, exit N that attachPaneCommand prints is never printed, and the docs describe a line the user does not see. I found this while working on the reconnect from #644, because the reconnect branch of the wrapper did not start either.

The fix

The script is wrapped in /usr/bin/env /bin/sh -c '<script>'. The exec now replaces bash with env, env runs sh, and the script runs to its end. sh is used directly and not through login, so it reads no profile. Nothing else changes: the pane still exits with the ssh status, and the line is the same text as before.

The new test runs the pane command through bash -c "exec -l …", the way libghostty runs it. On master it fails with an empty stdout; with the fix it prints the line and exits 23.

Verification

swift test (RemoteSessionTests, 26 tests) and make lint are clean. This is the first PR of the reconnect work discussed in #644; the reconnect PR is based on it.

…drop it

libghostty runs a surface command as bash -c "exec -l <command>", so the exec replaced the shell with
ssh and nothing after it ran: the pane never printed its "disconnected, exit N" line. Wrapping the script
in /usr/bin/env /bin/sh -c gives the exec to env and keeps sh non-login.

Claude-Session: https://claude.ai/code/session_01GiNNp4Fiq8JFqMxqz3N9x6

@umputun umputun left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@umputun
umputun merged commit 54f9bd4 into umputun:master Sep 25, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants