@@ -16,7 +16,7 @@ import (
16
16
// Returns stdout and stderr.
17
17
//
18
18
// scriptName is used only for readability of error strings.
19
- func sudoExecuteScript (host string , port int , c * ssh.SSHConfig , script , scriptName string ) (string , string , error ) {
19
+ func sudoExecuteScript (host string , port int , c * ssh.SSHConfig , script , scriptName string ) (stdout , stderr string , err error ) {
20
20
if c == nil {
21
21
return "" , "" , errors .New ("got nil SSHConfig" )
22
22
}
@@ -32,12 +32,12 @@ func sudoExecuteScript(host string, port int, c *ssh.SSHConfig, script, scriptNa
32
32
sshArgs = append (sshArgs , host , "--" , "sudo" , interpreter )
33
33
sshCmd := exec .Command (sshBinary , sshArgs ... )
34
34
sshCmd .Stdin = strings .NewReader (script )
35
- var stderr bytes.Buffer
36
- sshCmd .Stderr = & stderr
35
+ var buf bytes.Buffer
36
+ sshCmd .Stderr = & buf
37
37
logrus .Debugf ("executing ssh for script %q: %s %v" , scriptName , sshCmd .Path , sshCmd .Args )
38
38
out , err := sshCmd .Output ()
39
39
if err != nil {
40
- return string (out ), stderr .String (), fmt .Errorf ("failed to execute script %q: stdout=%q, stderr=%q: %w" , scriptName , string (out ), stderr .String (), err )
40
+ return string (out ), buf .String (), fmt .Errorf ("failed to execute script %q: stdout=%q, stderr=%q: %w" , scriptName , string (out ), buf .String (), err )
41
41
}
42
- return string (out ), stderr .String (), nil
42
+ return string (out ), buf .String (), nil
43
43
}
0 commit comments