Skip to content

Commit

Permalink
Printing the error of a failing ResolveCommand (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Feb 19, 2016
1 parent 85ef5e3 commit b6e21ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ Get a released version on: https://github.com/moul/advanced-ssh-config/releases

### master (unreleased)

* Printing the error of a failing ResolveCommand ([#117](https://github.com/moul/advanced-ssh-config/issues/117))
* Fix: `Gateways` field is no longer ignored when the `HostName` field is present ([#102](https://github.com/moul/advanced-ssh-config/issues/102))
* Ignore SIGHUP, close goroutines and export written bytes ([#112](https://github.com/moul/advanced-ssh-config/pull/112)) ([@QuentinPerez](https://github.com/QuentinPerez))
* Various documentation improvements ([@ashmatadeen](https://github.com/ashmatadeen), [@loliee](https://github.com/loliee), [@cerisier](https://github.com/cerisier))
Expand Down
12 changes: 9 additions & 3 deletions pkg/commands/proxy.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package commands

import (
"bytes"
"fmt"
"io"
"net"
Expand Down Expand Up @@ -178,12 +179,17 @@ func hostPrepare(host *config.Host) error {
return err
}

out, err := exec.Command(args[0], args[1:]...).Output()
if err != nil {
cmd := exec.Command(args[0], args[1:]...)
var stdout bytes.Buffer
var stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
Logger.Errorf("ResolveCommand failed: %s", stderr.String())
return err
}

host.HostName = strings.TrimSpace(fmt.Sprintf("%s", out))
host.HostName = strings.TrimSpace(fmt.Sprintf("%s", stdout.String()))
Logger.Debugf("Resolved host is: %s", host.HostName)
}
return nil
Expand Down

0 comments on commit b6e21ec

Please sign in to comment.