Skip to content

Commit

Permalink
Bugfix: update implicit config("*")
Browse files Browse the repository at this point in the history
  • Loading branch information
xwjdsh committed Jun 20, 2018
1 parent 2c2730f commit 6b9d474
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions sshconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,13 @@ func Update(p string, uo *UpdateOption) (*HostConfig, error) {
// Parse connect string
user, hostname, port := utils.ParseConnect(uo.Connect)
if user != "" {
updateHost.OwnConfig["user"] = user
uo.Config["user"] = user
}
if hostname != "" {
updateHost.OwnConfig["hostname"] = hostname
uo.Config["hostname"] = hostname
}
if port != "" {
updateHost.OwnConfig["port"] = port
uo.Config["port"] = port
}
}

Expand All @@ -321,6 +321,21 @@ func Update(p string, uo *UpdateOption) (*HostConfig, error) {
if len(host.Patterns) == 1 {
if i == 0 {
*host = *newHost
// for implicit "*"
find := false
for _, h := range configMap[fp].Hosts {
if host == h {
find = true
break
}
}
if !find {
newHost.Nodes = []ssh_config.Node{}
for k, v := range uo.Config {
newHost.Nodes = append(newHost.Nodes, ssh_config.NewKV(k, v))
}
configMap[fp].Hosts = append(configMap[fp].Hosts, newHost)
}
} else {
deleteHostFromConfig(configMap[fp], host)
}
Expand Down

0 comments on commit 6b9d474

Please # to comment.