From ebdd4d986f8c756398da99f56e8434f8c8a0470e Mon Sep 17 00:00:00 2001 From: Andreas Opferkuch Date: Mon, 21 May 2018 17:08:34 +0200 Subject: [PATCH] Fixes #41 - Issue with blank spaces in path Forgot some uses of exec.Command() outside of the "use" command. --- src/nvm.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/nvm.go b/src/nvm.go index 2bd8180..ae707c0 100644 --- a/src/nvm.go +++ b/src/nvm.go @@ -340,8 +340,9 @@ func uninstall(version string) { fmt.Printf("Uninstalling node v"+version+"...") v, _ := node.GetCurrentVersion() if v == version { - cmd := exec.Command(filepath.Join(env.root, "elevate.cmd"), "cmd", "/C", "rmdir", env.symlink) - cmd.Run() + runElevated(fmt.Sprintf(`"%s" cmd /C rmdir "%s"`, + filepath.Join(env.root, "elevate.cmd"), + filepath.Clean(env.symlink))) } e := os.RemoveAll(filepath.Join(env.root, "v"+version)) if e != nil { @@ -544,8 +545,12 @@ func enable() { } func disable() { - cmd := exec.Command(filepath.Join(env.root, "elevate.cmd"), "cmd", "/C", "rmdir", env.symlink) - cmd.Run() + if !runElevated(fmt.Sprintf(`"%s" cmd /C rmdir "%s"`, + filepath.Join(env.root, "elevate.cmd"), + filepath.Clean(env.symlink))) { + return + } + fmt.Println("nvm disabled") } -- GitLab