From 1e96aa845bd384614663cb416ed72bc1ff82f65f Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Thu, 8 Dec 2016 15:02:21 -0800 Subject: [PATCH] fix wait boot_command regex. Resolves #4268 --- builder/qemu/step_type_boot_command.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/builder/qemu/step_type_boot_command.go b/builder/qemu/step_type_boot_command.go index 804f7621d..f9f3c94ea 100644 --- a/builder/qemu/step_type_boot_command.go +++ b/builder/qemu/step_type_boot_command.go @@ -144,6 +144,7 @@ func vncSendString(c *vnc.ClientConn, original string) { special[""] = 0xFFE2 shiftedChars := "~!@#$%^&*()_+{}|:\"<>?" + waitRe := regexp.MustCompile(`^`) // TODO(mitchellh): Ripe for optimizations of some point, perhaps. for len(original) > 0 { @@ -339,16 +340,13 @@ func vncSendString(c *vnc.ClientConn, original string) { continue } - if strings.HasPrefix(original, "") { - re := regexp.MustCompile(`$`) - dstr := re.FindStringSubmatch(original) - if len(dstr) > 1 { - log.Printf("Special code %s found, sleeping", dstr[0]) - if dt, err := time.ParseDuration(dstr[1]); err == nil { - time.Sleep(dt) - original = original[len(dstr[0]):] - continue - } + waitMatch := waitRe.FindStringSubmatch(original) + if len(waitMatch) > 1 { + log.Printf("Special code %s found, sleeping", waitMatch[0]) + if dt, err := time.ParseDuration(waitMatch[1]); err == nil { + time.Sleep(dt) + original = original[len(waitMatch[0]):] + continue } }