feature: append path in process env util adds new env to start instead end of path entries list

master
amorozov 2024-06-28 16:55:30 +03:00
parent 194898b8a0
commit 525c37d8e3
1 changed files with 3 additions and 1 deletions

View File

@ -13,13 +13,15 @@ import (
var PathEnvironmentVariableName = "PATH" var PathEnvironmentVariableName = "PATH"
func AppendPath(cmd *exec.Cmd, newElements ...string) { func AppendPath(cmd *exec.Cmd, newElements ...string) {
pathEntries := GetPath(cmd) pathEntries := array_list.NewArrayList[string]()
for _, newPathEntry := range newElements { for _, newPathEntry := range newElements {
if !pathEntries.Contains(newPathEntry) { if !pathEntries.Contains(newPathEntry) {
pathEntries.Add(newPathEntry) pathEntries.Add(newPathEntry)
} }
} }
pathEntries.AddAll(GetPath(cmd))
SetPath(cmd, pathEntries.ToSliceUnsafe()...) SetPath(cmd, pathEntries.ToSliceUnsafe()...)
} }