Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

Commit4a7aca7

Browse files
committed
Use safeexec to get windows path
1 parent74b7fa4 commit4a7aca7

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

‎go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ require (
66
cdr.dev/slogv1.4.1
77
cdr.dev/wsepv0.0.0-20200728013649-82316a09813f
88
github.com/briandowns/spinnerv1.16.0
9+
github.com/cli/safeexecv1.0.0
910
github.com/fatih/colorv1.12.0
1011
github.com/google/go-cmpv0.5.6
1112
github.com/gorilla/websocketv1.4.2

‎go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5O
7878
github.com/chzyer/readlinev0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
7979
github.com/chzyer/testv0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=
8080
github.com/chzyer/testv0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
81+
github.com/cli/safeexecv1.0.0 h1:0VngyaIyqACHdcMNWfo6+KdUYnqEr2Sg+bSP1pdF+dI=
82+
github.com/cli/safeexecv1.0.0/go.mod h1:Z/D4tTN8Vs5gXYHDCbaM1S/anmEDnJb1iW0+EJ5zx3Q=
8183
github.com/client9/misspellv0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
8284
github.com/cncf/udpa/gov0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
8385
github.com/cncf/udpa/gov0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=

‎internal/cmd/configssh.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,19 @@ import (
66
"io/ioutil"
77
"net/url"
88
"os"
9-
"os/exec"
109
"os/user"
1110
"path/filepath"
1211
"runtime"
1312
"sort"
1413
"strings"
1514

16-
"cdr.dev/coder-cli/pkg/clog"
17-
15+
"github.com/cli/safeexec"
1816
"github.com/spf13/cobra"
1917
"golang.org/x/xerrors"
2018

2119
"cdr.dev/coder-cli/coder-sdk"
2220
"cdr.dev/coder-cli/internal/coderutil"
21+
"cdr.dev/coder-cli/pkg/clog"
2322
)
2423

2524
constsshStartToken="# ------------START-CODER-ENTERPRISE-----------"
@@ -162,7 +161,10 @@ func binPath() (string, error) {
162161
// if it isn't.
163162
ifruntime.GOOS=="windows" {
164163
binName:=filepath.Base(exePath)
165-
pathPath,err:=exec.LookPath(exePath)
164+
// We use safeexec instead of os/exec because os/exec returns paths in
165+
// the current working directory, which we will run into very often when
166+
// looking for our own path.
167+
pathPath,err:=safeexec.LookPath(binName)
166168
iferr!=nil {
167169
clog.LogWarn(
168170
"The current executable is not in $PATH.",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp