From e57e1408b26938c9d4569777053ed7b55c159420 Mon Sep 17 00:00:00 2001 From: Alex Quick Date: Mon, 16 Jan 2017 23:07:20 -0500 Subject: [PATCH] [common] add NewTokenizedShellCmd to ShellCmd --- plugins/common/common.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/common/common.go b/plugins/common/common.go index 31060a760..e124c4a68 100644 --- a/plugins/common/common.go +++ b/plugins/common/common.go @@ -22,11 +22,16 @@ type ShellCmd struct { // NewShellCmd returns a new ShellCmd struct func NewShellCmd(command string) *ShellCmd { items := strings.Split(command, " ") - cmd := items[0] - args := items[1:] + return NewTokenizedShellCmd(items...) +} + +// NewTokenizedShellCmd creates a new ShellCmd +func NewTokenizedShellCmd(command ...string) *ShellCmd { + cmd := command[0] + args := command[1:] return &ShellCmd{ Command: exec.Command(cmd, args...), - CommandString: command, + CommandString: strings.Join(command, " "), Args: args, ShowOutput: true, }