Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 10a19b1

Browse files
authored
Merge pull request #1062 from gtardif/fix_cli_moby_command_detect
Make Moby command detection (based on help output) more robust.
2 parents a87c583 + f55823b commit 10a19b1

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

cli/mobycli/exec.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"os"
2323
"os/exec"
2424
"os/signal"
25-
"strings"
25+
"regexp"
2626

2727
"github.com/spf13/cobra"
2828

@@ -112,9 +112,7 @@ func IsDefaultContextCommand(dockerCommand string) bool {
112112
if e != nil {
113113
fmt.Println(e)
114114
}
115-
output := string(b)
116-
contains := strings.Contains(output, "Usage:\tdocker "+dockerCommand)
117-
return contains
115+
return regexp.MustCompile("Usage:\\s*docker\\s*" + dockerCommand).Match(b)
118116
}
119117

120118
// ExecSilent executes a command and do redirect output to stdOut, return output

0 commit comments

Comments
 (0)