From 0577d3b97fcedaf02b5aaa19ac29bdd082599209 Mon Sep 17 00:00:00 2001 From: mjarkk Date: Wed, 12 Dec 2018 21:08:53 +0100 Subject: [PATCH] Removed the username / password savety check This check is not realy needed because the change that it will show up a second time is so low that this is more work to check than the change it actualy might happen --- pkg/commands/os.go | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/pkg/commands/os.go b/pkg/commands/os.go index 037f6da2e..d40a60e46 100644 --- a/pkg/commands/os.go +++ b/pkg/commands/os.go @@ -71,27 +71,13 @@ func (c *OSCommand) DetectUnamePass(command string, ask func(string) string) err errMessage, err := c.RunCommandWithOutputLive(command, func(word string) string { ttyText = ttyText + " " + word - type Prompt struct { - pattern string - canAskFor bool - } - prompts := map[string]Prompt{ - "password": { - pattern: `Password\s*for\s*'.+':`, - canAskFor: true, - }, - "username": { - pattern: `Username\s*for\s*'.+':`, - canAskFor: true, - }, + prompts := map[string]string{ + "password": `Password\s*for\s*'.+':`, + "username": `Username\s*for\s*'.+':`, } - for askFor, prompt := range prompts { - if !prompt.canAskFor { - continue - } - if match, _ := regexp.MatchString(prompt.pattern, ttyText); match { - prompt.canAskFor = false + for askFor, pattern := range prompts { + if match, _ := regexp.MatchString(pattern, ttyText); match { ttyText = "" return ask(askFor) }