diff --git a/main.go b/main.go index 99d2073..6f873d5 100644 --- a/main.go +++ b/main.go @@ -103,9 +103,12 @@ func main() { // run the script if script.IsPiped() { - script.Echo() + err = script.Echo() } else { - script.Run(*target, flag.Args()...) + err = script.Run(*target, flag.Args()...) + } + if err != nil { + log.Panic(err) } } diff --git a/script.go b/script.go index de5cd8e..9c56cda 100644 --- a/script.go +++ b/script.go @@ -97,7 +97,11 @@ func (s *Script) detachSignature(contents []byte) ([]byte, error) { return nil, err } defer sigWriter.Close() - io.Copy(sigWriter, block.ArmoredSignature.Body) + + _, err = io.Copy(sigWriter, block.ArmoredSignature.Body) + if err != nil { + return nil, err + } return contents, nil } @@ -162,12 +166,21 @@ func (s Script) Run(target string, args ...string) error { } // Echo prints the contents of the script to STDOUT -func (s Script) Echo() { +func (s Script) Echo() error { log.Println("Sending", s.Name(), "to STDOUT for more processing") - body, _ := s.Body() + + body, err := s.Body() + if err != nil { + return err + } defer body.Close() - io.Copy(os.Stdout, body) + _, err = io.Copy(os.Stdout, body) + if err != nil { + return err + } + + return nil } // Inspect checks whether an inspection was requested, and sends Script.Name() diff --git a/signature.go b/signature.go index fabe142..235b01e 100644 --- a/signature.go +++ b/signature.go @@ -74,7 +74,10 @@ func (s *Signature) Download() error { } defer file.Close() - io.Copy(file, body) + _, err = io.Copy(file, body) + if err != nil { + return nil + } return nil }