Skip to content

Commit

Permalink
Make IsWindows never return error
Browse files Browse the repository at this point in the history
  • Loading branch information
kke committed Feb 11, 2021
1 parent 86e96a6 commit 3c0da65
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,13 @@ func (c Connection) String() string {
}

// IsWindows returns true on windows hosts
func (c *Connection) IsWindows() (bool, error) {
func (c *Connection) IsWindows() bool {
if !c.IsConnected() {
return false, &NotConnectedError{c}
if client := c.configuredClient(); client != nil {
return client.IsWindows()
}
}

return c.client.IsWindows(), nil
return c.client.IsWindows()
}

// Exec runs a command on the host
Expand Down
4 changes: 2 additions & 2 deletions ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ func (c *SSH) Disconnect() {

// IsWindows is true when the host is running windows
func (c *SSH) IsWindows() bool {
if !c.knowOs {
if !c.knowOs && c.client != nil {
c.isWindows = c.Exec("cmd /c exit 0") == nil
c.knowOs = true

c.isWindows = c.Exec("cmd /c exit 0") == nil
}

return c.isWindows
Expand Down

0 comments on commit 3c0da65

Please sign in to comment.