handle editor having arguments

This commit is contained in:
Cory Bennett
2015-02-21 21:15:02 -08:00
parent 60f07bcdd6
commit cc5878fabc
2 changed files with 9 additions and 3 deletions
+4 -1
View File
@@ -18,7 +18,7 @@ export GOPATH=$(shell pwd)
build: build:
cd src/github.com/Netflix-Skunkworks/go-jira/jira; \ cd src/github.com/Netflix-Skunkworks/go-jira/jira; \
go install -v go get -v
all: all:
mkdir -p $(DIST); \ mkdir -p $(DIST); \
@@ -28,3 +28,6 @@ all:
echo "Building for $$p"; \ echo "Building for $$p"; \
GOOS=$${p/-*/} GOARCH=$${p/*-/} go build -v -o $(DIST)/jira-$$p; \ GOOS=$${p/-*/} GOARCH=$${p/*-/} go build -v -o $(DIST)/jira-$$p; \
done done
fmt:
gofmt -s -w jira
+5 -2
View File
@@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/kballard/go-shellquote"
"github.com/op/go-logging" "github.com/op/go-logging"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"io/ioutil" "io/ioutil"
@@ -247,8 +248,10 @@ func (c *Cli) editTemplate(template string, tmpFilePrefix string, templateData m
for true { for true {
if editing { if editing {
log.Debug("Running: %s %s", editor, tmpFileName) shell, _ := shellquote.Split(editor)
cmd := exec.Command(editor, tmpFileName) 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 cmd.Stdout, cmd.Stderr, cmd.Stdin = os.Stdout, os.Stderr, os.Stdin
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
log.Error("Failed to edit template with %s: %s", editor, err) log.Error("Failed to edit template with %s: %s", editor, err)