Skip to content

Commit c64332d

Browse files
yasithdevclaude
andcommitted
Use RawCommand() for SSH exec instead of joining split args
s.Command() shell-parses the input, losing the original quoting. RawCommand() preserves the exact string the client sent, which is then passed to sh -c like OpenSSH does. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f587b3f commit c64332d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

subsystems/vscode/vscodessh.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,13 @@ func StartSSHServerForVSCodeConnection(sessionID, addr string) *SSHServer {
4747
log.Printf("client connected: user=%s remote=%s", user, remote)
4848
defer log.Printf("client disconnected: user=%s remote=%s", user, remote)
4949
// Non-interactive command execution: run the command on the host.
50-
// Like OpenSSH, join all args into a single string and pass to sh -c
51-
// so shell operators (&&, |, etc.) work correctly.
50+
// Use RawCommand() to get the exact string the client sent, then
51+
// pass it to sh -c like OpenSSH does.
5252
if len(s.Command()) > 0 {
53-
cmdArgs := s.Command()
54-
log.Printf("exec request: user=%s remote=%s cmd=%q", user, remote, cmdArgs)
53+
rawCmd := s.RawCommand()
54+
log.Printf("exec request: user=%s remote=%s cmd=%q", user, remote, rawCmd)
5555

56-
cmdStr := strings.Join(cmdArgs, " ")
57-
cmd := exec.Command("sh", "-c", cmdStr)
56+
cmd := exec.Command("sh", "-c", rawCmd)
5857
cmd.Env = os.Environ()
5958
cmd.Stdin = s
6059
cmd.Stdout = s

0 commit comments

Comments
 (0)