This repository was archived by the owner on Aug 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ require (
6
6
cdr.dev/slog v1.4.0
7
7
cdr.dev/wsep v0.0.0-20200728013649-82316a09813f
8
8
github.com/briandowns/spinner v1.12.0
9
+ github.com/cli/safeexec v1.0.0
9
10
github.com/fatih/color v1.10.0
10
11
github.com/google/go-cmp v0.5.5
11
12
github.com/gorilla/websocket v1.4.2
Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5O
54
54
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e /go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI =
55
55
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8 =
56
56
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 /go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU =
57
+ github.com/cli/safeexec v1.0.0 h1:0VngyaIyqACHdcMNWfo6+KdUYnqEr2Sg+bSP1pdF+dI =
58
+ github.com/cli/safeexec v1.0.0 /go.mod h1:Z/D4tTN8Vs5gXYHDCbaM1S/anmEDnJb1iW0+EJ5zx3Q =
57
59
github.com/client9/misspell v0.3.4 /go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw =
58
60
github.com/coreos/bbolt v1.3.2 /go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk =
59
61
github.com/coreos/etcd v3.3.13+incompatible /go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE =
Original file line number Diff line number Diff line change @@ -6,20 +6,19 @@ import (
6
6
"io/ioutil"
7
7
"net/url"
8
8
"os"
9
- "os/exec"
10
9
"os/user"
11
10
"path/filepath"
12
11
"runtime"
13
12
"sort"
14
13
"strings"
15
14
16
- "cdr.dev/coder-cli/pkg/clog"
17
-
15
+ "github.com/cli/safeexec"
18
16
"github.com/spf13/cobra"
19
17
"golang.org/x/xerrors"
20
18
21
19
"cdr.dev/coder-cli/coder-sdk"
22
20
"cdr.dev/coder-cli/internal/coderutil"
21
+ "cdr.dev/coder-cli/pkg/clog"
23
22
)
24
23
25
24
const sshStartToken = "# ------------START-CODER-ENTERPRISE-----------"
@@ -181,7 +180,10 @@ func binPath() (string, error) {
181
180
// if it isn't.
182
181
if runtime .GOOS == "windows" {
183
182
binName := filepath .Base (exePath )
184
- pathPath , err := exec .LookPath (exePath )
183
+ // We use safeexec instead of os/exec because os/exec returns paths in
184
+ // the current working directory, which we will run into very often when
185
+ // looking for our own path.
186
+ pathPath , err := safeexec .LookPath (binName )
185
187
if err != nil {
186
188
clog .LogWarn (
187
189
"The current executable is not in $PATH." ,
You can’t perform that action at this time.
0 commit comments