Browse Source

bump mattn/go-shellwords v1.0.6

full diff: https://github.com/mattn/go-shellwords/compare/v1.0.5...v1.0.6

relevant changes:

- mattn/go-shellwords#24 Add dir option for parser
- mattn/go-shellwords#26 Fix backquote in part of argument
    - fixes mattn/go-shellwords#25 Backtick "eats" all runes until isSpace
- mattn/go-shellwords#28 Fix dollar quote
    - fixes mattn/go-shellwords#27 Multi-commands inside of command substitution are throwing "invalid command line string" errors
- mattn/go-shellwords#24 Add dir option for parser
- mattn/go-shellwords#24 Add dir option for parser
- mattn/go-shellwords#24 Add dir option for parser

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 5 years ago
parent
commit
7dee71e02f

+ 1 - 1
vendor.conf

@@ -9,7 +9,7 @@ github.com/Microsoft/opengcs                        a10967154e143a36014584a6f664
 
 github.com/creack/pty                               2769f65a3a94eb8f876f44a0459d24ae7ad2e488 # v1.1.7
 github.com/konsorten/go-windows-terminal-sequences  f55edac94c9bbba5d6182a4be46d86a2c9b5b50e # v1.0.2
-github.com/mattn/go-shellwords                      a72fbe27a1b0ed0df2f02754945044ce1456608b # v1.0.5
+github.com/mattn/go-shellwords                      36a9b3c57cb5caa559ff63fb7e9b585f1c00df75 # v1.0.6
 github.com/sirupsen/logrus                          839c75faf7f98a33d445d181f3018b5c3409a45e # v1.4.2
 github.com/tchap/go-patricia                        a7f0089c6f496e8e70402f61733606daa326cac5 # v2.3.0
 golang.org/x/net                                    f3200d17e092c607f615320ecaad13d87ad9a2b3

+ 1 - 1
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.

+ 7 - 9
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

+ 8 - 3
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
 	}

+ 6 - 2
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

+ 6 - 2
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