mirror of https://github.com/golang/go.git
cmd/go: allow ~ in middle of path, just not at beginning
An earlier CL disallowed ~ anywhere in GOPATH, to avoid problems with GOPATH='~/home' instead of GOPATH=~/home. But ~ is only special in the shell at the beginning of each of the paths in the list, and some paths do have ~ in the middle. So relax the requirement slightly. Fixes #4140. R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/7799045
This commit is contained in:
parent
f74eb6dbf7
commit
ffbcd89f62
|
|
@ -130,8 +130,11 @@ func main() {
|
|||
fmt.Fprintf(os.Stderr, "warning: GOPATH set to GOROOT (%s) has no effect\n", gopath)
|
||||
} else {
|
||||
for _, p := range filepath.SplitList(gopath) {
|
||||
if strings.Contains(p, "~") && runtime.GOOS != "windows" {
|
||||
fmt.Fprintf(os.Stderr, "go: GOPATH entry cannot contain shell metacharacter '~': %q\n", p)
|
||||
// Note: using HasPrefix instead of Contains because a ~ can appear
|
||||
// in the middle of directory elements, such as /tmp/git-1.8.2~rc3
|
||||
// or C:\PROGRA~1. Only ~ as a path prefix has meaning to the shell.
|
||||
if strings.HasPrefix(p, "~") {
|
||||
fmt.Fprintf(os.Stderr, "go: GOPATH entry cannot start with shell metacharacter '~': %q\n", p)
|
||||
os.Exit(2)
|
||||
}
|
||||
if build.IsLocalImport(p) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue