Skip to content

Commit

Permalink
fix: ssh stdout and stderr are empty
Browse files Browse the repository at this point in the history
  • Loading branch information
d-strobel committed Nov 15, 2023
1 parent 076099c commit 28eddcc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions connection/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,19 @@ func (c *Connection) runSSH(ctx context.Context, cmd string) (string, string, er
}

// Return the error if stderr has no value
if err != nil && stderrBytes == nil {
if err != nil && len(stderrBytes) == 0 {
return "", "", err
}

// Return stderr over the error when stderr has a value
if stderrBytes != nil {
if len(stderrBytes) > 0 {
return "", string(stderrBytes), nil
}

// Return error when stdout and stderr have no values
if len(stdoutBytes) == 0 && len(stderrBytes) == 0 {
return "", "", winerror.Errorf(winerror.WindowsError, "ssh session: stdout and stderr are empty")
}

return string(stdoutBytes), "", nil
}

0 comments on commit 28eddcc

Please sign in to comment.