mirror of https://github.com/docker/cli.git
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>
This commit is contained in:
parent
c07b1b275e
commit
6a26d370ad
|
@ -47,7 +47,7 @@ github.com/inconshreveable/mousetrap 76626ae9c91c4f2a10f34cad8ce8
|
||||||
github.com/jaguilar/vt100 ad4c4a5743050fb7f88ce968dca9422f72a0e3f2 git://github.com/tonistiigi/vt100.git
|
github.com/jaguilar/vt100 ad4c4a5743050fb7f88ce968dca9422f72a0e3f2 git://github.com/tonistiigi/vt100.git
|
||||||
github.com/json-iterator/go 0ff49de124c6f76f8494e194af75bde0f1a49a29 # 1.1.6
|
github.com/json-iterator/go 0ff49de124c6f76f8494e194af75bde0f1a49a29 # 1.1.6
|
||||||
github.com/konsorten/go-windows-terminal-sequences f55edac94c9bbba5d6182a4be46d86a2c9b5b50e # v1.0.2
|
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/matttproud/golang_protobuf_extensions c12348ce28de40eed0136aa2b644d0ee0650e56c # v1.0.1
|
github.com/matttproud/golang_protobuf_extensions c12348ce28de40eed0136aa2b644d0ee0650e56c # v1.0.1
|
||||||
github.com/Microsoft/go-winio 6c72808b55902eae4c5943626030429ff20f3b63 # v0.4.14
|
github.com/Microsoft/go-winio 6c72808b55902eae4c5943626030429ff20f3b63 # v0.4.14
|
||||||
github.com/Microsoft/hcsshim 672e52e9209d1e53718c1b6a7d68cc9272654ab5
|
github.com/Microsoft/hcsshim 672e52e9209d1e53718c1b6a7d68cc9272654ab5
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# go-shellwords
|
# 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)
|
[![Build Status](https://travis-ci.org/mattn/go-shellwords.svg?branch=master)](https://travis-ci.org/mattn/go-shellwords)
|
||||||
|
|
||||||
Parse line as shell words.
|
Parse line as shell words.
|
||||||
|
|
|
@ -40,6 +40,7 @@ type Parser struct {
|
||||||
ParseEnv bool
|
ParseEnv bool
|
||||||
ParseBacktick bool
|
ParseBacktick bool
|
||||||
Position int
|
Position int
|
||||||
|
Dir string
|
||||||
|
|
||||||
// If ParseEnv is true, use this for getenv.
|
// If ParseEnv is true, use this for getenv.
|
||||||
// If nil, use os.Getenv.
|
// If nil, use os.Getenv.
|
||||||
|
@ -51,6 +52,7 @@ func NewParser() *Parser {
|
||||||
ParseEnv: ParseEnv,
|
ParseEnv: ParseEnv,
|
||||||
ParseBacktick: ParseBacktick,
|
ParseBacktick: ParseBacktick,
|
||||||
Position: 0,
|
Position: 0,
|
||||||
|
Dir: "",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,11 +102,11 @@ loop:
|
||||||
if !singleQuoted && !doubleQuoted && !dollarQuote {
|
if !singleQuoted && !doubleQuoted && !dollarQuote {
|
||||||
if p.ParseBacktick {
|
if p.ParseBacktick {
|
||||||
if backQuote {
|
if backQuote {
|
||||||
out, err := shellRun(backtick)
|
out, err := shellRun(backtick, p.Dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
buf = out
|
buf = buf[:len(buf)-len(backtick)] + out
|
||||||
}
|
}
|
||||||
backtick = ""
|
backtick = ""
|
||||||
backQuote = !backQuote
|
backQuote = !backQuote
|
||||||
|
@ -117,15 +119,11 @@ loop:
|
||||||
if !singleQuoted && !doubleQuoted && !backQuote {
|
if !singleQuoted && !doubleQuoted && !backQuote {
|
||||||
if p.ParseBacktick {
|
if p.ParseBacktick {
|
||||||
if dollarQuote {
|
if dollarQuote {
|
||||||
out, err := shellRun(backtick)
|
out, err := shellRun(backtick, p.Dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if r == ')' {
|
buf = buf[:len(buf)-len(backtick)-2] + out
|
||||||
buf = buf[:len(buf)-len(backtick)-2] + out
|
|
||||||
} else {
|
|
||||||
buf = buf[:len(buf)-len(backtick)-1] + out
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
backtick = ""
|
backtick = ""
|
||||||
dollarQuote = !dollarQuote
|
dollarQuote = !dollarQuote
|
||||||
|
@ -155,7 +153,7 @@ loop:
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
case ';', '&', '|', '<', '>':
|
case ';', '&', '|', '<', '>':
|
||||||
if !(escaped || singleQuoted || doubleQuoted || backQuote) {
|
if !(escaped || singleQuoted || doubleQuoted || backQuote || dollarQuote) {
|
||||||
if r == '>' && len(buf) > 0 {
|
if r == '>' && len(buf) > 0 {
|
||||||
if c := buf[0]; '0' <= c && c <= '9' {
|
if c := buf[0]; '0' <= c && c <= '9' {
|
||||||
i -= 1
|
i -= 1
|
||||||
|
|
|
@ -9,14 +9,19 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func shellRun(line string) (string, error) {
|
func shellRun(line, dir string) (string, error) {
|
||||||
var b []byte
|
var b []byte
|
||||||
var err error
|
var err error
|
||||||
|
var cmd *exec.Cmd
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
b, err = exec.Command(os.Getenv("COMSPEC"), "/c", line).Output()
|
cmd = exec.Command(os.Getenv("COMSPEC"), "/c", line)
|
||||||
} else {
|
} 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 {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,13 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func shellRun(line string) (string, error) {
|
func shellRun(line, dir string) (string, error) {
|
||||||
shell := os.Getenv("SHELL")
|
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 err != nil {
|
||||||
if eerr, ok := err.(*exec.ExitError); ok {
|
if eerr, ok := err.(*exec.ExitError); ok {
|
||||||
b = eerr.Stderr
|
b = eerr.Stderr
|
||||||
|
|
|
@ -9,9 +9,13 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func shellRun(line string) (string, error) {
|
func shellRun(line, dir string) (string, error) {
|
||||||
shell := os.Getenv("COMSPEC")
|
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 err != nil {
|
||||||
if eerr, ok := err.(*exec.ExitError); ok {
|
if eerr, ok := err.(*exec.ExitError); ok {
|
||||||
b = eerr.Stderr
|
b = eerr.Stderr
|
||||||
|
|
Loading…
Reference in New Issue