aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Bell <scott@sctsm.com>2016-04-18 12:40:48 -0700
committerHan-Wen Nienhuys <hanwen@google.com>2016-04-20 10:39:07 +0000
commitde15db8e4b7d9627c2c0922002d1de9806af8564 (patch)
tree6e8c93dbf7f47f5759e33625ee0447af03d47949
parent2f6fccd33b9b1fc23ebb73ad4890698820f7174d (diff)
downloadgo-x-crypto-de15db8e4b7d9627c2c0922002d1de9806af8564.tar.xz
x/crypto/ssh: omit empty fields in error message
Although the signal and msg fields are assigned together, their values originate from the remote server and may be empty. Fixes golang/go#14251 Change-Id: I9d9094cc69f3c14bf1648af59951f6b6c7a71e0a Reviewed-on: https://go-review.googlesource.com/22196 Reviewed-by: Han-Wen Nienhuys <hanwen@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-rw-r--r--ssh/session.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/ssh/session.go b/ssh/session.go
index fd10cd1..09eb009 100644
--- a/ssh/session.go
+++ b/ssh/session.go
@@ -601,5 +601,12 @@ func (w Waitmsg) Lang() string {
}
func (w Waitmsg) String() string {
- return fmt.Sprintf("Process exited with: %v. Reason was: %v (%v)", w.status, w.msg, w.signal)
+ str := fmt.Sprintf("Process exited with status %v", w.status)
+ if w.signal != "" {
+ str += fmt.Sprintf(" from signal %v", w.signal)
+ }
+ if w.msg != "" {
+ str += fmt.Sprintf(". Reason was: %v", w.msg)
+ }
+ return str
}