From 7186fb3e3e2e981333108021a5619ab48a5a2d24 Mon Sep 17 00:00:00 2001 From: Cory Bennett Date: Sat, 21 Feb 2015 21:15:02 -0800 Subject: [PATCH] handle editor having arguments --- Makefile | 5 ++++- jira/cli/cli.go | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index c8629676..498495f5 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ export GOPATH=$(shell pwd) build: cd src/github.com/Netflix-Skunkworks/go-jira/jira; \ - go install -v + go get -v all: mkdir -p $(DIST); \ @@ -28,3 +28,6 @@ all: echo "Building for $$p"; \ GOOS=$${p/-*/} GOARCH=$${p/*-/} go build -v -o $(DIST)/jira-$$p; \ done + +fmt: + gofmt -s -w jira diff --git a/jira/cli/cli.go b/jira/cli/cli.go index 9bdb95a0..d68b2402 100644 --- a/jira/cli/cli.go +++ b/jira/cli/cli.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/json" "fmt" + "github.com/kballard/go-shellquote" "github.com/op/go-logging" "gopkg.in/yaml.v2" "io/ioutil" @@ -247,8 +248,10 @@ func (c *Cli) editTemplate(template string, tmpFilePrefix string, templateData m for true { if editing { - log.Debug("Running: %s %s", editor, tmpFileName) - cmd := exec.Command(editor, tmpFileName) + shell, _ := shellquote.Split(editor) + shell = append(shell, tmpFileName) + log.Debug("Running: %#v", shell) + cmd := exec.Command(shell[0], shell[1:]...) cmd.Stdout, cmd.Stderr, cmd.Stdin = os.Stdout, os.Stderr, os.Stdin if err := cmd.Run(); err != nil { log.Error("Failed to edit template with %s: %s", editor, err)