2
2
espelhamento de https://github.com/Hilbis/Hilbish sincronizado 2025-07-11 05:22:02 +00:00

fix: check if path has tilde prefix when trying to expand home

Esse commit está contido em:
TorchedSammy 2022-05-01 07:20:40 -04:00
commit 30b07bc98b
Assinado por: sammyette
ID da chave GPG: 904FC49417B44DCD

Ver arquivo

@ -153,9 +153,16 @@ func ForEach(tbl *rt.Table, cb func(key rt.Value, val rt.Value)) {
} }
} }
// ExpandHome expands ~ (tilde) in the path, changing it to the user home
// directory.
func ExpandHome(path string) string { func ExpandHome(path string) string {
curuser, _ := user.Current() if strings.HasPrefix(path, "~") {
homedir := curuser.HomeDir curuser, _ := user.Current()
homedir := curuser.HomeDir
return strings.Replace(path, "~", homedir, 1) return strings.Replace(path, "~", homedir, 1)
}
return path
} }