Skip to content

Commit 1c7f5c6

Browse files
committed
fix: use os.PathListSeparator
Use os.PathListSeparator instead of ":". This removes one blocker for a Windows port as the path separator on Windows is ";". Also use filepath.SplitList instead of strings.Split to correctly handle the (very unepected) case of an empty PATH in RemoveFromPath.
1 parent ea27fd5 commit 1c7f5c6

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

internal/cli/cli.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ func envCommand(logger *log.Logger, shimmedCommand string, args []string) error
545545
}
546546

547547
func setPath(paths []string) string {
548-
return strings.Join(paths, ":") + ":" + os.Getenv("PATH")
548+
return strings.Join(paths, string(os.PathListSeparator)) + string(os.PathListSeparator) + os.Getenv("PATH")
549549
}
550550

551551
func execCommand(logger *log.Logger, command string, args []string) error {

internal/paths/paths.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44
package paths
55

66
import (
7+
"path/filepath"
78
"strings"
89
)
910

1011
// RemoveFromPath returns the PATH without asdf shims path
1112
func RemoveFromPath(currentPath, pathToRemove string) string {
1213
var newPaths []string
1314

14-
for _, fspath := range strings.Split(currentPath, ":") {
15+
for _, fspath := range filepath.SplitList(currentPath) {
1516
if fspath != pathToRemove {
1617
newPaths = append(newPaths, fspath)
1718
}
1819
}
1920

20-
return strings.Join(newPaths, ":")
21+
return strings.Join(newPaths, string(filepath.ListSeparator))
2122
}

0 commit comments

Comments
 (0)