cmd/go/internal/modcmd: change -replace syntax from => to =
This avoids being forced to quote the argument to avoid being
interpreted as a shell redirection.
Fixes golang/go#26230.
Change-Id: I2c79d259290a8db18eacc94aeebabc89bc6e72e7
Reviewed-on: https://go-review.googlesource.com/122404
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
diff --git a/vendor/cmd/go/internal/modcmd/mod.go b/vendor/cmd/go/internal/modcmd/mod.go
index aa7a11a..d8ae1d9 100644
--- a/vendor/cmd/go/internal/modcmd/mod.go
+++ b/vendor/cmd/go/internal/modcmd/mod.go
@@ -57,7 +57,7 @@
add and drop an exclusion for the given module path and version.
Note that -exclude=path@version is a no-op if that exclusion already exists.
-The -replace=old@v=>new@w and -dropreplace=old@v flags
+The -replace=old@v=new@w and -dropreplace=old@v flags
add and drop a replacement of the given module path and version pair.
If the @v in old@v is omitted, the replacement applies to all versions
with the old module path. If the @v in new@v is omitted, the
@@ -397,10 +397,13 @@
// flagReplace implements the -replace flag.
func flagReplace(arg string) {
var i int
- if i = strings.Index(arg, "=>"); i < 0 {
- base.Fatalf("go mod: -replace=%s: need old@v=>new[@v] (missing =>)", arg)
+ if i = strings.Index(arg, "="); i < 0 {
+ base.Fatalf("go mod: -replace=%s: need old@v=new[@v] (missing =)", arg)
}
old, new := strings.TrimSpace(arg[:i]), strings.TrimSpace(arg[i+2:])
+ if strings.HasPrefix(new, ">") {
+ base.Fatalf("go mod: -replace=%s: separator between old and new is =, not =>", arg)
+ }
var oldPath, oldVersion string
if i = strings.Index(old, "@"); i < 0 {
oldPath = old