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

Commit64a2214

Browse files
authored
fix(agent/agentcontainers): remove shellquote in favor of %q (#18544)
1 parentb6c493d commit64a2214

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

‎agent/agentcontainers/api_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2040,7 +2040,7 @@ func TestAPI(t *testing.T) {
20402040
// Verify commands were executed through the custom shell and environment.
20412041
require.NotEmpty(t,fakeExec.commands,"commands should be executed")
20422042

2043-
// Want: /bin/custom-shell -c "docker ps--all--quiet--no-trunc"
2043+
// Want: /bin/custom-shell -c'"docker" "ps" "--all" "--quiet" "--no-trunc"'
20442044
require.Equal(t,testShell,fakeExec.commands[0][0],"custom shell should be used")
20452045
ifruntime.GOOS=="windows" {
20462046
require.Equal(t,"/c",fakeExec.commands[0][1],"shell should be called with /c on Windows")
@@ -2049,6 +2049,7 @@ func TestAPI(t *testing.T) {
20492049
}
20502050
require.Len(t,fakeExec.commands[0],3,"command should have 3 arguments")
20512051
require.GreaterOrEqual(t,strings.Count(fakeExec.commands[0][2]," "),2,"command/script should have multiple arguments")
2052+
require.True(t,strings.HasPrefix(fakeExec.commands[0][2],`"docker" "ps"`),"command should start with\"docker\"\"ps\"")
20522053

20532054
// Verify the environment was set on the command.
20542055
lastCmd:=fakeExec.getLastCommand()

‎agent/agentcontainers/execer.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package agentcontainers
22

33
import (
44
"context"
5+
"fmt"
56
"os/exec"
67
"runtime"
7-
8-
"github.com/kballard/go-shellquote"
8+
"strings"
99

1010
"cdr.dev/slog"
1111
"github.com/coder/coder/v2/agent/agentexec"
@@ -56,7 +56,10 @@ func (e *commandEnvExecer) prepare(ctx context.Context, inName string, inArgs ..
5656
caller="/c"
5757
}
5858
name=shell
59-
args= []string{caller,shellquote.Join(append([]string{inName},inArgs...)...)}
59+
for_,arg:=rangeappend([]string{inName},inArgs...) {
60+
args=append(args,fmt.Sprintf("%q",arg))
61+
}
62+
args= []string{caller,strings.Join(args," ")}
6063
returnname,args,dir,env
6164
}
6265

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp