From 45c5c5b40fafc621db14b2bcafc0cfad0d397dbb Mon Sep 17 00:00:00 2001 From: ssongliu Date: Fri, 12 Jun 2026 11:17:08 +0800 Subject: [PATCH] fix: resolve SSH key generation issue (#13027) --- agent/utils/cmd/cmdx.go | 17 +---------------- core/utils/cmd/cmdx.go | 17 +---------------- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/agent/utils/cmd/cmdx.go b/agent/utils/cmd/cmdx.go index b87c886ab..376f6b054 100644 --- a/agent/utils/cmd/cmdx.go +++ b/agent/utils/cmd/cmdx.go @@ -240,7 +240,7 @@ func (c *CommandHelper) pipeContext() (context.Context, context.CancelFunc) { func (c *CommandHelper) buildPipeCommands(ctx context.Context, commands []PipeCommand) []*exec.Cmd { cmds := make([]*exec.Cmd, 0, len(commands)) for _, item := range commands { - cmdItem := exec.CommandContext(ctx, item.Name, filterEmptyArgs(item.Args)...) + cmdItem := exec.CommandContext(ctx, item.Name, item.Args...) cmdItem.Env = append(os.Environ(), c.env...) cmdItem.Env = append(cmdItem.Env, item.Env...) cmdItem.Dir = c.workDir @@ -305,7 +305,6 @@ func (c *CommandHelper) run(name string, arg ...string) (string, error) { var newContext context.Context var cancel context.CancelFunc var outputFile *os.File - arg = filterEmptyArgs(arg) if c.timeout != 0 { if c.context == nil { @@ -412,20 +411,6 @@ func (c *CommandHelper) run(name string, arg ...string) (string, error) { } } -func filterEmptyArgs(args []string) []string { - if len(args) == 0 { - return args - } - filtered := args[:0] - for _, arg := range args { - if arg == "" { - continue - } - filtered = append(filtered, arg) - } - return filtered -} - func contextDone(ctx context.Context) <-chan struct{} { if ctx == nil { return nil diff --git a/core/utils/cmd/cmdx.go b/core/utils/cmd/cmdx.go index d29ecca1e..dceafd870 100644 --- a/core/utils/cmd/cmdx.go +++ b/core/utils/cmd/cmdx.go @@ -219,7 +219,7 @@ func (c *CommandHelper) pipeContext() (context.Context, context.CancelFunc) { func (c *CommandHelper) buildPipeCommands(ctx context.Context, commands []PipeCommand) []*exec.Cmd { cmds := make([]*exec.Cmd, 0, len(commands)) for _, item := range commands { - cmdItem := exec.CommandContext(ctx, item.Name, filterEmptyArgs(item.Args)...) + cmdItem := exec.CommandContext(ctx, item.Name, item.Args...) cmdItem.Env = append(os.Environ(), c.env...) cmdItem.Env = append(cmdItem.Env, item.Env...) cmdItem.Dir = c.workDir @@ -284,7 +284,6 @@ func (c *CommandHelper) run(name string, arg ...string) (string, error) { var newContext context.Context var cancel context.CancelFunc var outputFile *os.File - arg = filterEmptyArgs(arg) if c.timeout != 0 { if c.context == nil { @@ -379,20 +378,6 @@ func (c *CommandHelper) run(name string, arg ...string) (string, error) { } } -func filterEmptyArgs(args []string) []string { - if len(args) == 0 { - return args - } - filtered := args[:0] - for _, arg := range args { - if arg == "" { - continue - } - filtered = append(filtered, arg) - } - return filtered -} - func contextDone(ctx context.Context) <-chan struct{} { if ctx == nil { return nil