cmd/swarm: use expandPath for swarm cli path parameters

This commit is contained in:
Evgeny Danienko
2018-09-25 15:54:47 +03:00
parent 1f45ba9bb1
commit 09dde380f9
2 changed files with 13 additions and 3 deletions

View File

@ -138,6 +138,12 @@ func upload(ctx *cli.Context) {
// 3. cleans the path, e.g. /a/b/../c -> /a/c
// Note, it has limitations, e.g. ~someuser/tmp will not be expanded
func expandPath(p string) string {
if i := strings.Index(p, ":"); i > 0 {
return p
}
if i := strings.Index(p, "@"); i > 0 {
return p
}
if strings.HasPrefix(p, "~/") || strings.HasPrefix(p, "~\\") {
if home := homeDir(); home != "" {
p = home + p[1:]