builder/virtualbox: trim whitespace when getting version

This commit is contained in:
Mitchell Hashimoto 2013-07-01 10:59:04 -07:00
parent 19f757a273
commit 9cf78edcf0
2 changed files with 5 additions and 3 deletions

View File

@ -13,6 +13,7 @@ IMPROVEMENTS:
BUG FIXES:
* core: More plugin server fixes that avoid hangs on OS X 10.7 [GH-87]
* virtualbox: More robust version parsing for uploading guest additions. [GH-69]
## 0.1.2 (June 29, 2013)

View File

@ -124,11 +124,12 @@ func (d *VBox42Driver) Version() (string, error) {
return "", err
}
log.Printf("VBoxManage --version output: %s", stdout.String())
versionOutput := strings.TrimSpace(stdout.String())
log.Printf("VBoxManage --version output: %s", versionOutput)
versionRe := regexp.MustCompile("[^.0-9]")
matches := versionRe.Split(stdout.String(), 2)
matches := versionRe.Split(versionOutput, 2)
if len(matches) == 0 {
return "", fmt.Errorf("No version found: %s", stdout.String())
return "", fmt.Errorf("No version found: %s", versionOutput)
}
log.Printf("VirtualBox version: %s", matches[0])