@@ -52,7 +52,7 @@ func (rsf *ReverseSSHFS) Prepare() error {
52
52
sshArgs = append (sshArgs , "-p" , strconv .Itoa (rsf .Port ))
53
53
}
54
54
sshArgs = append (sshArgs , rsf .Host , "--" )
55
- sshArgs = append (sshArgs , "mkdir" , "-p" , strconv . Quote (rsf .RemotePath ))
55
+ sshArgs = append (sshArgs , "mkdir" , "-p" , addQuotes (rsf .RemotePath ))
56
56
sshCmd := exec .Command (sshBinary , sshArgs ... )
57
57
logrus .Debugf ("executing ssh for preparing sshfs: %s %v" , sshCmd .Path , sshCmd .Args )
58
58
out , err := sshCmd .CombinedOutput ()
@@ -141,7 +141,7 @@ func (rsf *ReverseSSHFS) Start() error {
141
141
sshArgs = append (sshArgs , "-p" , strconv .Itoa (rsf .Port ))
142
142
}
143
143
sshArgs = append (sshArgs , rsf .Host , "--" )
144
- sshArgs = append (sshArgs , "sshfs" , strconv . Quote (":" + rsf .LocalPath ), strconv . Quote (rsf .RemotePath ), "-o" , "slave" )
144
+ sshArgs = append (sshArgs , "sshfs" , addQuotes (":" + rsf .LocalPath ), addQuotes (rsf .RemotePath ), "-o" , "slave" )
145
145
if rsf .Readonly {
146
146
sshArgs = append (sshArgs , "-o" , "ro" )
147
147
}
@@ -252,6 +252,18 @@ func (rsf *ReverseSSHFS) Start() error {
252
252
return nil
253
253
}
254
254
255
+ func addQuotes (input string ) string {
256
+ input = strconv .Quote (input )
257
+ // exec.Command on Windows would escape wrapping double quotes in a way, which is not compatible
258
+ // with passing arguments into bash shell over ssh, replacing with single quotes as a workaround.
259
+ if runtime .GOOS == "windows" {
260
+ input = strings .TrimPrefix (input , "\" " )
261
+ input = strings .TrimSuffix (input , "\" " )
262
+ return fmt .Sprintf (`'%s'` , input )
263
+ }
264
+ return input
265
+ }
266
+
255
267
func (rsf * ReverseSSHFS ) waitForRemoteReady () error {
256
268
scriptName := "wait-for-remote-ready"
257
269
scriptTemplate := `#!/bin/sh
0 commit comments