2
3
Fork 0
Browse Source

Fixes tilde expansion

master
sloum 12 months ago
parent
commit
c33810a637
  1. 7
      utils.go

7
utils.go

@ -55,16 +55,19 @@ func ExpandedAbsFilepath(p string) string {
} else {
i := strings.IndexRune(p, '/')
var u string
var remainder string
if i < 0 {
u = p[1:]
remainder = ""
} else {
u = p[1:i]
remainder = p[i:]
}
usr, err := user.Lookup(u)
if err != nil {
p = filepath.Join("/home", u, p[i:])
p = filepath.Join("/home", u, remainder)
} else {
p = filepath.Join(usr.HomeDir, p[i:])
p = filepath.Join(usr.HomeDir, remainder)
}
}
} else if !strings.HasPrefix(p, "/") {

Loading…
Cancel
Save