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

fix(agent/agentcontainers): remove shellquote in favor of %q#18544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletionagent/agentcontainers/api_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2040,7 +2040,7 @@ func TestAPI(t *testing.T) {
// Verify commands were executed through the custom shell and environment.
require.NotEmpty(t, fakeExec.commands, "commands should be executed")

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

// Verify the environment was set on the command.
lastCmd := fakeExec.getLastCommand()
Expand Down
9 changes: 6 additions & 3 deletionsagent/agentcontainers/execer.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,10 +2,10 @@ package agentcontainers

import (
"context"
"fmt"
"os/exec"
"runtime"

"github.com/kballard/go-shellquote"
"strings"

"cdr.dev/slog"
"github.com/coder/coder/v2/agent/agentexec"
Expand DownExpand Up@@ -56,7 +56,10 @@ func (e *commandEnvExecer) prepare(ctx context.Context, inName string, inArgs ..
caller = "/c"
}
name = shell
args = []string{caller, shellquote.Join(append([]string{inName}, inArgs...)...)}
for _, arg := range append([]string{inName}, inArgs...) {
args = append(args, fmt.Sprintf("%q", arg))
}
args = []string{caller, strings.Join(args, " ")}
return name, args, dir, env
}

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp