Merge pull request #1309 from hashicorp/issue-1308

Fix panic when using -field with read or write with a non-string value.
This commit is contained in:
Jeff Mitchell 2016-04-07 18:17:13 -04:00
commit 1bf6551807
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 {