1
0
mirror of https://github.com/go-task/task.git synced 2025-08-10 22:42:19 +02:00

Update vendor directory

This commit is contained in:
Andrey Nering
2019-02-24 11:45:32 -03:00
parent a98f803d87
commit 9dbb503c23
5 changed files with 32 additions and 13 deletions

2
vendor/modules.txt vendored
View File

@@ -38,7 +38,7 @@ golang.org/x/sys/unix
golang.org/x/sys/windows golang.org/x/sys/windows
# gopkg.in/yaml.v2 v2.2.1 # gopkg.in/yaml.v2 v2.2.1
gopkg.in/yaml.v2 gopkg.in/yaml.v2
# mvdan.cc/sh v2.6.3+incompatible # mvdan.cc/sh v2.6.4-0.20190222161105-3c71c7be1070+incompatible
mvdan.cc/sh/expand mvdan.cc/sh/expand
mvdan.cc/sh/interp mvdan.cc/sh/interp
mvdan.cc/sh/shell mvdan.cc/sh/shell

View File

@@ -373,7 +373,11 @@ func (cfg *Config) wordField(wps []syntax.WordPart, ql quoteLevel) ([]fieldPart,
case *syntax.Lit: case *syntax.Lit:
s := x.Value s := x.Value
if i == 0 && ql == quoteNone { if i == 0 && ql == quoteNone {
s = cfg.expandUser(s) if prefix, rest := cfg.expandUser(s); prefix != "" {
// TODO: return two separate fieldParts,
// like in wordFields?
s = prefix + rest
}
} }
if ql == quoteDouble && strings.Contains(s, "\\") { if ql == quoteDouble && strings.Contains(s, "\\") {
buf := cfg.strBuilder() buf := cfg.strBuilder()
@@ -468,7 +472,12 @@ func (cfg *Config) wordFields(wps []syntax.WordPart) ([][]fieldPart, error) {
case *syntax.Lit: case *syntax.Lit:
s := x.Value s := x.Value
if i == 0 { if i == 0 {
s = cfg.expandUser(s) prefix, rest := cfg.expandUser(s)
curField = append(curField, fieldPart{
quote: quoteSingle,
val: prefix,
})
s = rest
} }
if strings.Contains(s, "\\") { if strings.Contains(s, "\\") {
buf := cfg.strBuilder() buf := cfg.strBuilder()
@@ -562,28 +571,27 @@ func (cfg *Config) quotedElems(pe *syntax.ParamExp) []string {
return nil return nil
} }
func (cfg *Config) expandUser(field string) string { func (cfg *Config) expandUser(field string) (prefix, rest string) {
if len(field) == 0 || field[0] != '~' { if len(field) == 0 || field[0] != '~' {
return field return "", field
} }
name := field[1:] name := field[1:]
rest := ""
if i := strings.Index(name, "/"); i >= 0 { if i := strings.Index(name, "/"); i >= 0 {
rest = name[i:] rest = name[i:]
name = name[:i] name = name[:i]
} }
if name == "" { if name == "" {
return cfg.Env.Get("HOME").String() + rest return cfg.Env.Get("HOME").String(), rest
} }
if vr := cfg.Env.Get("HOME " + name); vr.IsSet() { if vr := cfg.Env.Get("HOME " + name); vr.IsSet() {
return vr.String() + rest return vr.String(), rest
} }
u, err := user.Lookup(name) u, err := user.Lookup(name)
if err != nil { if err != nil {
return field return "", field
} }
return u.HomeDir + rest return u.HomeDir, rest
} }
func findAllIndex(pattern, name string, n int) [][]int { func findAllIndex(pattern, name string, n int) [][]int {

View File

@@ -1182,6 +1182,10 @@ func (r *Runner) findExecutable(file string, exts []string) string {
return "" return ""
} }
func driveLetter(c byte) bool {
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
}
// splitList is like filepath.SplitList, but always using the unix path // splitList is like filepath.SplitList, but always using the unix path
// list separator ':'. On Windows, it also makes sure not to split // list separator ':'. On Windows, it also makes sure not to split
// [A-Z]:[/\]. // [A-Z]:[/\].
@@ -1198,8 +1202,7 @@ func splitList(path string) []string {
for i := 0; i < len(list); i++ { for i := 0; i < len(list); i++ {
s := list[i] s := list[i]
switch { switch {
case len(s) != 1, s[0] < 'A', s[0] > 'Z': case len(s) != 1, !driveLetter(s[0]):
// not a disk name
case i+1 >= len(list): case i+1 >= len(list):
// last element // last element
case strings.IndexAny(list[i+1], `/\`) != 0: case strings.IndexAny(list[i+1], `/\`) != 0:

View File

@@ -19,7 +19,7 @@ import (
func (r *Runner) bashTest(ctx context.Context, expr syntax.TestExpr, classic bool) string { func (r *Runner) bashTest(ctx context.Context, expr syntax.TestExpr, classic bool) string {
switch x := expr.(type) { switch x := expr.(type) {
case *syntax.Word: case *syntax.Word:
return r.literal(x) return r.document(x)
case *syntax.ParenTest: case *syntax.ParenTest:
return r.bashTest(ctx, x.X, classic) return r.bashTest(ctx, x.X, classic)
case *syntax.BinaryTest: case *syntax.BinaryTest:

View File

@@ -3,4 +3,12 @@
// Package shell contains high-level features that use the syntax, expand, and // Package shell contains high-level features that use the syntax, expand, and
// interp packages under the hood. // interp packages under the hood.
//
// Please note that this package uses POSIX Shell syntax. As such, path names on
// Windows need to use double backslashes or be within single quotes when given
// to functions like Fields. For example:
//
// shell.Fields("echo /foo/bar") // on Unix-like
// shell.Fields("echo C:\\foo\\bar") // on Windows
// shell.Fields("echo 'C:\foo\bar'") // on Windows, with quotes
package shell package shell