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:
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…
x
Reference in New Issue
Block a user