mirror of https://github.com/Hilbis/Hilbish
fix: dont append to path if dir is already there (resolves #52)
parent
2c2eb8d69a
commit
0afca3d4f6
10
lua.go
10
lua.go
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue