1
0
mirror of https://github.com/go-task/task.git synced 2025-04-17 12:06:30 +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
# gopkg.in/yaml.v2 v2.2.1
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/interp
mvdan.cc/sh/shell

View File

@ -373,7 +373,11 @@ func (cfg *Config) wordField(wps []syntax.WordPart, ql quoteLevel) ([]fieldPart,
case *syntax.Lit:
s := x.Value
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, "\\") {
buf := cfg.strBuilder()
@ -468,7 +472,12 @@ func (cfg *Config) wordFields(wps []syntax.WordPart) ([][]fieldPart, error) {
case *syntax.Lit:
s := x.Value
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, "\\") {
buf := cfg.strBuilder()
@ -562,28 +571,27 @@ func (cfg *Config) quotedElems(pe *syntax.ParamExp) []string {
return nil
}
func (cfg *Config) expandUser(field string) string {
func (cfg *Config) expandUser(field string) (prefix, rest string) {
if len(field) == 0 || field[0] != '~' {
return field
return "", field
}
name := field[1:]
rest := ""
if i := strings.Index(name, "/"); i >= 0 {
rest = name[i:]
name = name[:i]
}
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() {
return vr.String() + rest
return vr.String(), rest
}
u, err := user.Lookup(name)
if err != nil {
return field
return "", field
}
return u.HomeDir + rest
return u.HomeDir, rest
}
func findAllIndex(pattern, name string, n int) [][]int {

View File

@ -1182,6 +1182,10 @@ func (r *Runner) findExecutable(file string, exts []string) string {
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
// list separator ':'. On Windows, it also makes sure not to split
// [A-Z]:[/\].
@ -1198,8 +1202,7 @@ func splitList(path string) []string {
for i := 0; i < len(list); i++ {
s := list[i]
switch {
case len(s) != 1, s[0] < 'A', s[0] > 'Z':
// not a disk name
case len(s) != 1, !driveLetter(s[0]):
case i+1 >= len(list):
// last element
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 {
switch x := expr.(type) {
case *syntax.Word:
return r.literal(x)
return r.document(x)
case *syntax.ParenTest:
return r.bashTest(ctx, x.X, classic)
case *syntax.BinaryTest:

View File

@ -3,4 +3,12 @@
// Package shell contains high-level features that use the syntax, expand, and
// 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