summaryrefslogtreecommitdiff
path: root/vendor/github.com/mattn/go-shellwords
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/mattn/go-shellwords')
-rw-r--r--vendor/github.com/mattn/go-shellwords/.travis.yml12
-rw-r--r--vendor/github.com/mattn/go-shellwords/README.md2
-rw-r--r--vendor/github.com/mattn/go-shellwords/go.test.sh12
-rw-r--r--vendor/github.com/mattn/go-shellwords/shellwords.go16
-rw-r--r--vendor/github.com/mattn/go-shellwords/util_go15.go11
-rw-r--r--vendor/github.com/mattn/go-shellwords/util_posix.go8
-rw-r--r--vendor/github.com/mattn/go-shellwords/util_windows.go8
7 files changed, 49 insertions, 20 deletions
diff --git a/vendor/github.com/mattn/go-shellwords/.travis.yml b/vendor/github.com/mattn/go-shellwords/.travis.yml
index 16d1430aa..6294d337f 100644
--- a/vendor/github.com/mattn/go-shellwords/.travis.yml
+++ b/vendor/github.com/mattn/go-shellwords/.travis.yml
@@ -1,8 +1,14 @@
language: go
+sudo: false
go:
- tip
+
before_install:
- - go get github.com/mattn/goveralls
- - go get golang.org/x/tools/cmd/cover
+ - go get -t -v ./...
+
script:
- - $HOME/gopath/bin/goveralls -repotoken 2FMhp57u8LcstKL9B190fLTcEnBtAAiEL
+ - ./go.test.sh
+
+after_success:
+ - bash <(curl -s https://codecov.io/bash)
+
diff --git a/vendor/github.com/mattn/go-shellwords/README.md b/vendor/github.com/mattn/go-shellwords/README.md
index b1d235c78..9e1e65045 100644
--- a/vendor/github.com/mattn/go-shellwords/README.md
+++ b/vendor/github.com/mattn/go-shellwords/README.md
@@ -1,6 +1,6 @@
# go-shellwords
-[![Coverage Status](https://coveralls.io/repos/mattn/go-shellwords/badge.png?branch=master)](https://coveralls.io/r/mattn/go-shellwords?branch=master)
+[![codecov](https://codecov.io/gh/mattn/go-shellwords/branch/master/graph/badge.svg)](https://codecov.io/gh/mattn/go-shellwords)
[![Build Status](https://travis-ci.org/mattn/go-shellwords.svg?branch=master)](https://travis-ci.org/mattn/go-shellwords)
Parse line as shell words.
diff --git a/vendor/github.com/mattn/go-shellwords/go.test.sh b/vendor/github.com/mattn/go-shellwords/go.test.sh
new file mode 100644
index 000000000..a7deaca96
--- /dev/null
+++ b/vendor/github.com/mattn/go-shellwords/go.test.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+
+set -e
+echo "" > coverage.txt
+
+for d in $(go list ./... | grep -v vendor); do
+ go test -coverprofile=profile.out -covermode=atomic "$d"
+ if [ -f profile.out ]; then
+ cat profile.out >> coverage.txt
+ rm profile.out
+ fi
+done
diff --git a/vendor/github.com/mattn/go-shellwords/shellwords.go b/vendor/github.com/mattn/go-shellwords/shellwords.go
index 41429d8f2..2dca7f136 100644
--- a/vendor/github.com/mattn/go-shellwords/shellwords.go
+++ b/vendor/github.com/mattn/go-shellwords/shellwords.go
@@ -40,6 +40,7 @@ type Parser struct {
ParseEnv bool
ParseBacktick bool
Position int
+ Dir string
// If ParseEnv is true, use this for getenv.
// If nil, use os.Getenv.
@@ -51,6 +52,7 @@ func NewParser() *Parser {
ParseEnv: ParseEnv,
ParseBacktick: ParseBacktick,
Position: 0,
+ Dir: "",
}
}
@@ -100,11 +102,11 @@ loop:
if !singleQuoted && !doubleQuoted && !dollarQuote {
if p.ParseBacktick {
if backQuote {
- out, err := shellRun(backtick)
+ out, err := shellRun(backtick, p.Dir)
if err != nil {
return nil, err
}
- buf = out
+ buf = buf[:len(buf)-len(backtick)] + out
}
backtick = ""
backQuote = !backQuote
@@ -117,15 +119,11 @@ loop:
if !singleQuoted && !doubleQuoted && !backQuote {
if p.ParseBacktick {
if dollarQuote {
- out, err := shellRun(backtick)
+ out, err := shellRun(backtick, p.Dir)
if err != nil {
return nil, err
}
- if r == ')' {
- buf = buf[:len(buf)-len(backtick)-2] + out
- } else {
- buf = buf[:len(buf)-len(backtick)-1] + out
- }
+ buf = buf[:len(buf)-len(backtick)-2] + out
}
backtick = ""
dollarQuote = !dollarQuote
@@ -155,7 +153,7 @@ loop:
continue
}
case ';', '&', '|', '<', '>':
- if !(escaped || singleQuoted || doubleQuoted || backQuote) {
+ if !(escaped || singleQuoted || doubleQuoted || backQuote || dollarQuote) {
if r == '>' && len(buf) > 0 {
if c := buf[0]; '0' <= c && c <= '9' {
i -= 1
diff --git a/vendor/github.com/mattn/go-shellwords/util_go15.go b/vendor/github.com/mattn/go-shellwords/util_go15.go
index 180f00f0b..ddcbf229e 100644
--- a/vendor/github.com/mattn/go-shellwords/util_go15.go
+++ b/vendor/github.com/mattn/go-shellwords/util_go15.go
@@ -9,14 +9,19 @@ import (
"strings"
)
-func shellRun(line string) (string, error) {
+func shellRun(line, dir string) (string, error) {
var b []byte
var err error
+ var cmd *exec.Cmd
if runtime.GOOS == "windows" {
- b, err = exec.Command(os.Getenv("COMSPEC"), "/c", line).Output()
+ cmd = exec.Command(os.Getenv("COMSPEC"), "/c", line)
} else {
- b, err = exec.Command(os.Getenv("SHELL"), "-c", line).Output()
+ cmd = exec.Command(os.Getenv("SHELL"), "-c", line)
}
+ if dir != "" {
+ cmd.Dir = dir
+ }
+ b, err = cmd.Output()
if err != nil {
return "", err
}
diff --git a/vendor/github.com/mattn/go-shellwords/util_posix.go b/vendor/github.com/mattn/go-shellwords/util_posix.go
index eaf1011d6..3aef2c4d7 100644
--- a/vendor/github.com/mattn/go-shellwords/util_posix.go
+++ b/vendor/github.com/mattn/go-shellwords/util_posix.go
@@ -9,9 +9,13 @@ import (
"strings"
)
-func shellRun(line string) (string, error) {
+func shellRun(line, dir string) (string, error) {
shell := os.Getenv("SHELL")
- b, err := exec.Command(shell, "-c", line).Output()
+ cmd := exec.Command(shell, "-c", line)
+ if dir != "" {
+ cmd.Dir = dir
+ }
+ b, err := cmd.Output()
if err != nil {
if eerr, ok := err.(*exec.ExitError); ok {
b = eerr.Stderr
diff --git a/vendor/github.com/mattn/go-shellwords/util_windows.go b/vendor/github.com/mattn/go-shellwords/util_windows.go
index e46f89a1f..cda685091 100644
--- a/vendor/github.com/mattn/go-shellwords/util_windows.go
+++ b/vendor/github.com/mattn/go-shellwords/util_windows.go
@@ -9,9 +9,13 @@ import (
"strings"
)
-func shellRun(line string) (string, error) {
+func shellRun(line, dir string) (string, error) {
shell := os.Getenv("COMSPEC")
- b, err := exec.Command(shell, "/c", line).Output()
+ cmd := exec.Command(shell, "/c", line)
+ if dir != "" {
+ cmd.Dir = dir
+ }
+ b, err := cmd.Output()
if err != nil {
if eerr, ok := err.(*exec.ExitError); ok {
b = eerr.Stderr