Repository navigation
Description
Reported from the 2026-10-07 demo. Confirmed, with the exact generated argv.
$ spawn connect chem-debug -- 'free -m; tail /var/log/x'
bash: line 1: free -m; tail /var/log/x: No such file or directory # exit 127
$ spawn connect chem-debug -- tail -25 /var/log/x # works
The mechanism
shellQuoteArgs (cmd/connect.go:181) single-quotes each post--- argument
and joins them. Dumping the generated remote command for three inputs:
args=["free -m; tail /var/log/x"] -> 'free -m; tail /var/log/x'
args=["tail" "-25" "/var/log/x"] -> 'tail' '-25' '/var/log/x'
args=["bash" "-lc" "a && b"] -> 'bash' '-lc' 'a && b'
The first is one single-quoted word, so the remote login shell looks for a
command literally named free -m; tail /var/log/x, does not find it, and exits
127. The other two are correct.
This is #369's fix, working as designed, over-correcting
#369 was the opposite bug: the old code space-joined argv into one blob and
re-wrapped it in bash -c '…', so -- bash -lc "a && b" became
bash -c 'bash -lc a && b' and -lc got no argument. Per-argument quoting fixed
that correctly. It just also removed the ability to pass a command string.
Worth noting for whoever fixes this: real ssh does no quoting at all — it
space-joins argv and lets the remote shell re-parse, which is why ssh h bash -lc "a && b" is broken for ssh too, and why everyone single-quotes for ssh. So
"behave like ssh" and "keep #369 fixed" are in tension if taken literally. They
are reconcilable by looking at the argument count.
Suggested fix
Branch on len(args) after --:
- exactly one argument → pass it through verbatim, unquoted. The remote
shell parses it. This is preciselyssh host 'cmd string', and it is what a
single quoted argument unambiguously means. - two or more → quote each, as today. Preserves connect: '-- bash -lc "<cmd>"' mangles multi-token commands (argv re-split) #369.
Both forms then work, and the rule is explainable in one sentence: one argument is
a shell command line, several arguments are an argv.
A regression test should pin both directions, since this is now the second
time one was fixed by breaking the other:
{"free -m; tail /x"} -> free -m; tail /x
{"bash", "-lc", "a && b"} -> 'bash' '-lc' 'a && b'
cmd/connect_oneshot_test.go is the natural home, and it already covers the #369
case.
Severity: low — the multi-word form works and is documented. But exit 127 with a
No such file or directory naming the user's whole command reads like the remote
box is broken, which costs more debugging time than the bug deserves.
Environment: spawn v0.123.0.
Activity
fix(cmd): exit non-zero when a confirmation prompt is declined; fix c…