updating github.com/mattn/go-shellwords to v1.0.5

This commit is contained in:
Davanum Srinivas 2019-06-14 11:09:05 -04:00
parent b713287e43
commit 1a5cfb7aca
No known key found for this signature in database
GPG Key ID: 80D83A796103BF59
5 changed files with 30 additions and 12 deletions

4
go.mod
View File

@ -96,7 +96,7 @@ require (
github.com/lithammer/dedent v1.1.0 github.com/lithammer/dedent v1.1.0
github.com/lpabon/godbc v0.1.1 // indirect github.com/lpabon/godbc v0.1.1 // indirect
github.com/magiconair/properties v1.8.1 // indirect github.com/magiconair/properties v1.8.1 // indirect
github.com/mattn/go-shellwords v0.0.0-20180605041737-f8471b0a71de // indirect github.com/mattn/go-shellwords v1.0.5 // indirect
github.com/mesos/mesos-go v0.0.9 // indirect github.com/mesos/mesos-go v0.0.9 // indirect
github.com/mholt/caddy v0.0.0-20180213163048-2de495001514 github.com/mholt/caddy v0.0.0-20180213163048-2de495001514
github.com/miekg/dns v0.0.0-20160614162101-5d001d020961 github.com/miekg/dns v0.0.0-20160614162101-5d001d020961
@ -323,7 +323,7 @@ replace (
github.com/magiconair/properties => github.com/magiconair/properties v1.8.1 github.com/magiconair/properties => github.com/magiconair/properties v1.8.1
github.com/mailru/easyjson => github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 github.com/mailru/easyjson => github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329
github.com/marstr/guid => github.com/marstr/guid v0.0.0-20170427235115-8bdf7d1a087c github.com/marstr/guid => github.com/marstr/guid v0.0.0-20170427235115-8bdf7d1a087c
github.com/mattn/go-shellwords => github.com/mattn/go-shellwords v0.0.0-20180605041737-f8471b0a71de github.com/mattn/go-shellwords => github.com/mattn/go-shellwords v1.0.5
github.com/matttproud/golang_protobuf_extensions => github.com/matttproud/golang_protobuf_extensions v1.0.1 github.com/matttproud/golang_protobuf_extensions => github.com/matttproud/golang_protobuf_extensions v1.0.1
github.com/mesos/mesos-go => github.com/mesos/mesos-go v0.0.9 github.com/mesos/mesos-go => github.com/mesos/mesos-go v0.0.9
github.com/mholt/caddy => github.com/mholt/caddy v0.0.0-20180213163048-2de495001514 github.com/mholt/caddy => github.com/mholt/caddy v0.0.0-20180213163048-2de495001514

4
go.sum
View File

@ -255,8 +255,8 @@ github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/marstr/guid v0.0.0-20170427235115-8bdf7d1a087c h1:N7uWGS2fTwH/4BwxbHiJZNAFTSJ5yPU0emHsQWvkxEY= github.com/marstr/guid v0.0.0-20170427235115-8bdf7d1a087c h1:N7uWGS2fTwH/4BwxbHiJZNAFTSJ5yPU0emHsQWvkxEY=
github.com/marstr/guid v0.0.0-20170427235115-8bdf7d1a087c/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho= github.com/marstr/guid v0.0.0-20170427235115-8bdf7d1a087c/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho=
github.com/mattn/go-shellwords v0.0.0-20180605041737-f8471b0a71de h1:ryDLMbZGgf2bSdLfdQFaJuuP4No40cDUt62Mdv+3TW8= github.com/mattn/go-shellwords v1.0.5 h1:JhhFTIOslh5ZsPrpa3Wdg8bF0WI3b44EMblmU9wIsXc=
github.com/mattn/go-shellwords v0.0.0-20180605041737-f8471b0a71de/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o= github.com/mattn/go-shellwords v1.0.5/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mesos/mesos-go v0.0.9 h1:w8V5sOEnxzHZ2kAOy273v/HgbolyI6XI+qe5jx5u+Y0= github.com/mesos/mesos-go v0.0.9 h1:w8V5sOEnxzHZ2kAOy273v/HgbolyI6XI+qe5jx5u+Y0=

1
vendor/github.com/mattn/go-shellwords/go.mod generated vendored Normal file
View File

@ -0,0 +1 @@
module github.com/mattn/go-shellwords

View File

@ -4,6 +4,7 @@ import (
"errors" "errors"
"os" "os"
"regexp" "regexp"
"strings"
) )
var ( var (
@ -21,13 +22,17 @@ func isSpace(r rune) bool {
return false return false
} }
func replaceEnv(s string) string { func replaceEnv(getenv func(string) string, s string) string {
if getenv == nil {
getenv = os.Getenv
}
return envRe.ReplaceAllStringFunc(s, func(s string) string { return envRe.ReplaceAllStringFunc(s, func(s string) string {
s = s[1:] s = s[1:]
if s[0] == '{' { if s[0] == '{' {
s = s[1 : len(s)-1] s = s[1 : len(s)-1]
} }
return os.Getenv(s) return getenv(s)
}) })
} }
@ -35,10 +40,18 @@ type Parser struct {
ParseEnv bool ParseEnv bool
ParseBacktick bool ParseBacktick bool
Position int Position int
// If ParseEnv is true, use this for getenv.
// If nil, use os.Getenv.
Getenv func(string) string
} }
func NewParser() *Parser { func NewParser() *Parser {
return &Parser{ParseEnv, ParseBacktick, 0} return &Parser{
ParseEnv: ParseEnv,
ParseBacktick: ParseBacktick,
Position: 0,
}
} }
func (p *Parser) Parse(line string) ([]string, error) { func (p *Parser) Parse(line string) ([]string, error) {
@ -73,7 +86,7 @@ loop:
backtick += string(r) backtick += string(r)
} else if got { } else if got {
if p.ParseEnv { if p.ParseEnv {
buf = replaceEnv(buf) buf = replaceEnv(p.Getenv, buf)
} }
args = append(args, buf) args = append(args, buf)
buf = "" buf = ""
@ -108,7 +121,11 @@ loop:
if err != nil { if err != nil {
return nil, err return nil, err
} }
buf = out if r == ')' {
buf = buf[:len(buf)-len(backtick)-2] + out
} else {
buf = buf[:len(buf)-len(backtick)-1] + out
}
} }
backtick = "" backtick = ""
dollarQuote = !dollarQuote dollarQuote = !dollarQuote
@ -119,7 +136,7 @@ loop:
} }
case '(': case '(':
if !singleQuoted && !doubleQuoted && !backQuote { if !singleQuoted && !doubleQuoted && !backQuote {
if !dollarQuote && len(buf) > 0 && buf == "$" { if !dollarQuote && strings.HasSuffix(buf, "$") {
dollarQuote = true dollarQuote = true
buf += "(" buf += "("
continue continue
@ -159,7 +176,7 @@ loop:
if got { if got {
if p.ParseEnv { if p.ParseEnv {
buf = replaceEnv(buf) buf = replaceEnv(p.Getenv, buf)
} }
args = append(args, buf) args = append(args, buf)
} }

2
vendor/modules.txt vendored
View File

@ -588,7 +588,7 @@ github.com/mailru/easyjson/jlexer
github.com/mailru/easyjson/jwriter github.com/mailru/easyjson/jwriter
# github.com/marstr/guid v0.0.0-20170427235115-8bdf7d1a087c => github.com/marstr/guid v0.0.0-20170427235115-8bdf7d1a087c # github.com/marstr/guid v0.0.0-20170427235115-8bdf7d1a087c => github.com/marstr/guid v0.0.0-20170427235115-8bdf7d1a087c
github.com/marstr/guid github.com/marstr/guid
# github.com/mattn/go-shellwords v0.0.0-20180605041737-f8471b0a71de => github.com/mattn/go-shellwords v0.0.0-20180605041737-f8471b0a71de # github.com/mattn/go-shellwords v1.0.5 => github.com/mattn/go-shellwords v1.0.5
github.com/mattn/go-shellwords github.com/mattn/go-shellwords
# github.com/matttproud/golang_protobuf_extensions v1.0.1 => github.com/matttproud/golang_protobuf_extensions v1.0.1 # github.com/matttproud/golang_protobuf_extensions v1.0.1 => github.com/matttproud/golang_protobuf_extensions v1.0.1
github.com/matttproud/golang_protobuf_extensions/pbutil github.com/matttproud/golang_protobuf_extensions/pbutil