Fix panic when using -field with read or write with a non-string value.

Fixes #1308
This commit is contained in:
Jeff Mitchell 2016-04-07 22:16:33 +00:00
parent 650d40a258
commit 759915bb55
2 changed files with 4 additions and 4 deletions

View File

@ -70,9 +70,9 @@ func (c *ReadCommand) Run(args []string) int {
// directly print the message. If mitchellh/cli exposes method
// to print without CR, this check needs to be removed.
if reflect.TypeOf(c.Ui).String() == "*cli.BasicUi" {
fmt.Fprintf(os.Stdout, val.(string))
fmt.Fprintf(os.Stdout, fmt.Sprintf("%v", val))
} else {
c.Ui.Output(val.(string))
c.Ui.Output(fmt.Sprintf("%v", val))
}
return 0
} else {

View File

@ -82,9 +82,9 @@ func (c *WriteCommand) Run(args []string) int {
// directly print the message. If mitchellh/cli exposes method
// to print without CR, this check needs to be removed.
if reflect.TypeOf(c.Ui).String() == "*cli.BasicUi" {
fmt.Fprintf(os.Stdout, val.(string))
fmt.Fprintf(os.Stdout, fmt.Sprintf("%v", val))
} else {
c.Ui.Output(val.(string))
c.Ui.Output(fmt.Sprintf("%v", val))
}
return 0
} else {