Skip to content

Commit

Permalink
handle leftover errors properly
Browse files Browse the repository at this point in the history
  • Loading branch information
ellotheth committed Mar 4, 2016
1 parent 1ac11fb commit b0432a7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
7 changes: 5 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
21 changes: 17 additions & 4 deletions script.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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()
Expand Down
5 changes: 4 additions & 1 deletion signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit b0432a7

Please sign in to comment.