diff --git a/main.go b/main.go index df588a8..d640ecc 100644 --- a/main.go +++ b/main.go @@ -32,6 +32,10 @@ func init() { log.Lmicroseconds|log.Lshortfile) } +// I actually don't even know if this works or not......... +// Changes can be seen in windows system properties fucking thing +// But not in new terminals +// And rerunning the program even with a new terminal will func main() { currentPath := os.Getenv("PATH") paths := strings.Split(currentPath, ";") @@ -75,9 +79,35 @@ func main() { } for _, path := range alwaysInclude { - if !contains(cleanPaths, path) { - cleanPaths = append(cleanPaths, path) + path = filepath.Clean(path) + if !filepath.IsAbs(path) { + var err error + path, err = filepath.Abs(path) + if err != nil { + Error.Printf("error getting absolute path for %v: %v", path, err) + return + } } + path = filepath.FromSlash(path) + + fhandle, err := os.Open(path) + if err != nil { + if os.IsNotExist(err) { + Warning.Printf("Path %v does not exist", path) + continue + } + Warning.Printf("Error opening path %v: %v", path, err) + continue + } + fhandle.Close() + + if slices.Contains(cleanPaths, path) { + Warning.Printf("Path %v already exists in cleanPaths", path) + continue + } + + cleanPaths = append(cleanPaths, path) + log.Printf("Added path %v", path) } newPath := strings.Join(cleanPaths, ";")