Skip to content

Commit 3e26af4

Browse files
committed
Use os.Executable instead of pwd/argv0
1 parent cd7ae28 commit 3e26af4

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

rocketpool-cli/update/update.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"net/http"
77
"os"
88
"os/exec"
9-
"path/filepath"
109
"runtime"
1110
"strings"
1211

@@ -68,14 +67,10 @@ func forkCommand(binaryPath string, yes bool, args ...string) *exec.Cmd {
6867
}
6968

7069
func Update(c *cli.Context) error {
71-
// Get the pwd and argv[0]
72-
pwd, err := os.Getwd()
70+
oldBinaryPath, err := os.Executable()
7371
if err != nil {
74-
return err
72+
return fmt.Errorf("error getting path of current executable: %w", err)
7573
}
76-
argv0 := os.Args[0]
77-
78-
oldBinaryPath := filepath.Join(pwd, argv0)
7974

8075
// Validate the OS and architecture
8176
err = validateOsArch()

0 commit comments

Comments
 (0)