Skip to content

Commit 2bcc368

Browse files
committed
Do not mix src/dst spawned process when having two remote endpoints in scw cp.
1 parent 8495227 commit 2bcc368

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

cp.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,23 +80,23 @@ func runCp(cmd *Command, args []string) {
8080
// execCmd contains the ssh connection + the remoteCommand
8181
execCmd := append(NewSSHExecCmd(server.PublicAddress.IP, false, remoteCommand))
8282
log.Debugf("Executing: ssh %s", strings.Join(execCmd, " "))
83-
spawn := exec.Command("ssh", execCmd...)
83+
spawnSrc := exec.Command("ssh", execCmd...)
8484

85-
tarOutputStream, err = spawn.StdoutPipe()
85+
tarOutputStream, err = spawnSrc.StdoutPipe()
8686
if err != nil {
8787
log.Fatal(err)
8888
}
89-
tarErrorStream, err = spawn.StderrPipe()
89+
tarErrorStream, err = spawnSrc.StderrPipe()
9090
if err != nil {
9191
log.Fatal(err)
9292
}
9393

94-
err = spawn.Start()
94+
err = spawnSrc.Start()
9595
if err != nil {
9696
log.Fatalf("Failed to start ssh command: %v", err)
9797
}
9898

99-
defer spawn.Wait()
99+
defer spawnSrc.Wait()
100100

101101
io.Copy(os.Stderr, tarErrorStream)
102102
} else if source == "-" { // stdin
@@ -151,27 +151,27 @@ func runCp(cmd *Command, args []string) {
151151
// execCmd contains the ssh connection + the remoteCommand
152152
execCmd := append(NewSSHExecCmd(server.PublicAddress.IP, false, remoteCommand))
153153
log.Debugf("Executing: ssh %s", strings.Join(execCmd, " "))
154-
spawn := exec.Command("ssh", execCmd...)
154+
spawnDst := exec.Command("ssh", execCmd...)
155155

156-
untarInputStream, err := spawn.StdinPipe()
156+
untarInputStream, err := spawnDst.StdinPipe()
157157
if err != nil {
158158
log.Fatal(err)
159159
}
160-
untarErrorStream, err := spawn.StderrPipe()
160+
untarErrorStream, err := spawnDst.StderrPipe()
161161
if err != nil {
162162
log.Fatal(err)
163163
}
164-
untarOutputStream, err := spawn.StdoutPipe()
164+
untarOutputStream, err := spawnDst.StdoutPipe()
165165
if err != nil {
166166
log.Fatal(err)
167167
}
168168

169-
err = spawn.Start()
169+
err = spawnDst.Start()
170170
if err != nil {
171171
log.Fatalf("Failed to start ssh command: %v", err)
172172
}
173173

174-
defer spawn.Wait()
174+
defer spawnDst.Wait()
175175

176176
io.Copy(untarInputStream, tarOutputStream)
177177
io.Copy(os.Stderr, untarErrorStream)

0 commit comments

Comments
 (0)