X-Git-Url: https://ruderich.org/simon/gitweb/?p=safcm%2Fsafcm.git;a=blobdiff_plain;f=cmd%2Fsafcm%2Fsync.go;h=70aaf47e4c8f5c364247fa4fe0c05e239bb5d79b;hp=77e83c4187592ca1bd5cc31e44da3f4acfb4830d;hb=a8023b74bdd3d85cb0f3a55485887d133d2c0946;hpb=5d6cc7f14a4bacc36bf3a23cd735a75ad4a90f1d diff --git a/cmd/safcm/sync.go b/cmd/safcm/sync.go index 77e83c4..70aaf47 100644 --- a/cmd/safcm/sync.go +++ b/cmd/safcm/sync.go @@ -122,7 +122,8 @@ func MainSync(args []string) error { return fmt.Errorf("no hosts found") } - isTTY := term.IsTerminal(int(os.Stdout.Fd())) + isTTY := term.IsTerminal(int(os.Stdout.Fd())) && + term.IsTerminal(int(os.Stderr.Fd())) done := make(chan bool) // Collect events from all hosts and print them @@ -226,10 +227,7 @@ func MainSync(args []string) error { func hostsToSync(names []string, allHosts *config.Hosts, allGroups map[string][]string) ([]*config.Host, error) { - detectedMap := make(map[string]bool) - for _, x := range config.TransitivelyDetectedGroups(allGroups) { - detectedMap[x] = true - } + detectedMap := config.TransitivelyDetectedGroups(allGroups) const detectedErr = ` @@ -249,13 +247,13 @@ are only available after the hosts were contacted. nameMatched := make(map[string]bool) // To detect typos we must check all given names but one host can be // matched by multiple names (e.g. two groups with overlapping hosts) - hostMatched := make(map[string]bool) + hostAdded := make(map[string]bool) var res []*config.Host for _, host := range allHosts.List { if nameMap[host.Name] { res = append(res, host) - hostMatched[host.Name] = true + hostAdded[host.Name] = true nameMatched[host.Name] = true } @@ -266,9 +264,9 @@ are only available after the hosts were contacted. } for _, x := range groups { if nameMap[x] { - if !hostMatched[host.Name] { + if !hostAdded[host.Name] { res = append(res, host) - hostMatched[host.Name] = true + hostAdded[host.Name] = true } nameMatched[x] = true }