From 74826c25ca2221711d072a50ab12785fbf0a88a8 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Thu, 7 Apr 2016 22:16:33 +0000 Subject: [PATCH] Fix panic when using -field with read or write with a non-string value. Fixes #1308 --- command/read.go | 4 ++-- command/write.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/command/read.go b/command/read.go index 39b8218554..6cdde13d71 100644 --- a/command/read.go +++ b/command/read.go @@ -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 { diff --git a/command/write.go b/command/write.go index e289da28ad..0342f5dbb7 100644 --- a/command/write.go +++ b/command/write.go @@ -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 {