From fcb4b307c6f43aa0c4c2c8dc4a61406f8db40527 Mon Sep 17 00:00:00 2001 From: Dingjun Date: Sat, 8 Apr 2017 11:43:48 +0800 Subject: [PATCH] exit non-zero on error --- obfssh/ssh.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/obfssh/ssh.go b/obfssh/ssh.go index 3accecb..7930179 100644 --- a/obfssh/ssh.go +++ b/obfssh/ssh.go @@ -260,21 +260,33 @@ func main() { } } + hasErr := false + if !cfg.NotRunCmd { if cmd != "" { if d, err := client.RunCmd(cmd); err != nil { log.Println(err) + hasErr = true } else { //log.Printf("%s", string(d)) fmt.Printf("%s", string(d)) } } else { if err := client.Shell(); err != nil { + hasErr = true log.Println(err) } } } - client.Run() + + if err := client.Run(); err != nil { + log.Println(err) + hasErr = true + } + + if hasErr { + os.Exit(1) + } } func parseForwardAddr(s string) []string {