Skip to content

Commit

Permalink
Merge pull request coreybutler#965 from nineninesevenfour/fix-932-pat…
Browse files Browse the repository at this point in the history
…h-with-spaces

fix issue coreybutler#932
  • Loading branch information
coreybutler authored Oct 10, 2023
2 parents a73ef54 + 6c175fa commit 9c37af6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/nvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -1182,16 +1182,19 @@ func updateRootDir(path string) {
}

func elevatedRun(name string, arg ...string) (bool, error) {
ok, err := run("cmd", append([]string{"/C", name}, arg...)...)
ok, err := run("cmd", nil, append([]string{"/C", name}, arg...)...)
if err != nil {
ok, err = run(filepath.Join(env.root, "elevate.cmd"), append([]string{"cmd", "/C", name}, arg...)...)
ok, err = run("elevate.cmd", &env.root, append([]string{"cmd", "/C", name}, arg...)...)
}

return ok, err
}

func run(name string, arg ...string) (bool, error) {
func run(name string, dir *string, arg ...string) (bool, error) {
c := exec.Command(name, arg...)
if dir != nil {
c.Dir = *dir
}
var stderr bytes.Buffer
c.Stderr = &stderr
err := c.Run()
Expand Down

0 comments on commit 9c37af6

Please sign in to comment.