diff --git a/cmd/main.go b/cmd/main.go index 74d795995ce4..daa11d798c8a 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -344,15 +344,19 @@ func setup(c *cli.Context, n int) { } } -func removePassword(uri string) { +func removePassword(uris ...string) { args := make([]string, len(os.Args)) copy(args, os.Args) - uri2 := utils.RemovePassword(uri) - if uri2 != uri { - for i, a := range os.Args { - if a == uri { - args[i] = uri2 - break + var idx int + for _, uri := range uris { + uri2 := utils.RemovePassword(uri) + if uri2 != uri { + for i := idx; i < len(os.Args); i++ { + if os.Args[i] == uri { + args[i] = uri2 + idx = i + 1 + break + } } } } diff --git a/cmd/sync.go b/cmd/sync.go index 6ee7794f75f2..1b1aab24bc66 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -411,8 +411,7 @@ func doSync(c *cli.Context) error { // Windows support `\` and `/` as its separator, Unix only use `/` srcURL := c.Args().Get(0) dstURL := c.Args().Get(1) - removePassword(srcURL) - removePassword(dstURL) + removePassword(srcURL, dstURL) if runtime.GOOS == "windows" { if !strings.Contains(srcURL, "://") { srcURL = strings.Replace(srcURL, "\\", "/", -1)