zrcadlo
https://github.com/Hilbis/Hilbish
synchronizováno 2025-07-18 16:52:02 +00:00
fix: check if path has tilde prefix when trying to expand home
Tento commit je obsažen v:
rodič
db437905e0
revize
30b07bc98b
13
util/util.go
13
util/util.go
@ -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 {
|
||||
curuser, _ := user.Current()
|
||||
homedir := curuser.HomeDir
|
||||
if strings.HasPrefix(path, "~") {
|
||||
curuser, _ := user.Current()
|
||||
homedir := curuser.HomeDir
|
||||
|
||||
return strings.Replace(path, "~", homedir, 1)
|
||||
return strings.Replace(path, "~", homedir, 1)
|
||||
}
|
||||
|
||||
return path
|
||||
}
|
||||
|
||||
|
Načítá se…
x
Odkázat v novém úkolu
Zablokovat Uživatele