diff --git a/internal/flags/flags.go b/internal/flags/flags.go index 0ae2c6a512ef..9e3719632977 100644 --- a/internal/flags/flags.go +++ b/internal/flags/flags.go @@ -23,7 +23,7 @@ import ( "math/big" "os" "os/user" - "path" + "path/filepath" "strings" "github.com/ethereum/go-ethereum/common/math" @@ -319,7 +319,7 @@ func expandPath(p string) string { p = home + p[1:] } } - return path.Clean(os.ExpandEnv(p)) + return filepath.Clean(os.ExpandEnv(p)) } func HomeDir() string { diff --git a/internal/flags/flags_test.go b/internal/flags/flags_test.go index a0d4af7ca360..f9073cc97e31 100644 --- a/internal/flags/flags_test.go +++ b/internal/flags/flags_test.go @@ -25,11 +25,13 @@ import ( func TestPathExpansion(t *testing.T) { user, _ := user.Current() tests := map[string]string{ - "/home/someuser/tmp": "/home/someuser/tmp", - "~/tmp": user.HomeDir + "/tmp", - "~thisOtherUser/b/": "~thisOtherUser/b", - "$DDDXXX/a/b": "/tmp/a/b", - "/a/b/": "/a/b", + "/home/someuser/tmp": "/home/someuser/tmp", + "~/tmp": user.HomeDir + "/tmp", + "~thisOtherUser/b/": "~thisOtherUser/b", + "$DDDXXX/a/b": "/tmp/a/b", + "/a/b/": "/a/b", + "C:\\Documents\\Newsletters\\": "C:\\Documents\\Newsletters\\", + "C:\\": "C:\\", } os.Setenv("DDDXXX", "/tmp") for test, expected := range tests {