2
2
mirror of https://github.com/Hilbis/Hilbish synced 2025-04-02 03:33:22 +00:00

fix: dont append to path if dir is already there (resolves #52)

This commit is contained in:
sammy 2021-05-15 22:23:21 -04:00
parent 2c2eb8d69a
commit 0afca3d4f6
No known key found for this signature in database
GPG Key ID: 50EE40A2809851F5

10
lua.go
View File

@ -123,10 +123,14 @@ func hshalias(L *lua.LState) int {
}
func hshappendPath(L *lua.LState) int {
path := L.CheckString(1)
path = strings.Replace(path, "~", curuser.HomeDir, 1)
dir := L.CheckString(1)
dir = strings.Replace(dir, "~", curuser.HomeDir, 1)
pathenv := os.Getenv("PATH")
os.Setenv("PATH", os.Getenv("PATH") + ":" + path)
// if dir isnt already in $PATH, add it
if !strings.Contains(pathenv, dir) {
os.Setenv("PATH", pathenv + ":" + dir)
}
return 0
}