Skip to content

Commit 278a3a2

Browse files
committed
fix: use in built xargs only for pipeline commands
1 parent abfe414 commit 278a3a2

3 files changed

Lines changed: 19 additions & 0 deletions

File tree

pkg/devspace/pipeline/engine/basichandler/commands/xargs.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"io/ioutil"
77
"strings"
8+
"time"
89

910
"github.com/loft-sh/devspace/pkg/devspace/pipeline/engine/types"
1011
"mvdan.cc/sh/v3/interp"
@@ -16,6 +17,8 @@ type XArgsOptions struct {
1617
Delimiter string
1718
}
1819

20+
var XArgsFocusCommands = map[string]bool{}
21+
1922
func XArgs(ctx context.Context, args []string, handler types.ExecHandler) error {
2023
options := &XArgsOptions{
2124
Delimiter: " ",
@@ -26,6 +29,10 @@ func XArgs(ctx context.Context, args []string, handler types.ExecHandler) error
2629
return err
2730
} else if len(args) == 0 {
2831
return errXArgsUsage
32+
} else if !XArgsFocusCommands[args[0]] {
33+
newArgs := []string{"xargs"}
34+
newArgs = append(newArgs, args...)
35+
return interp.DefaultExecHandler(2*time.Second)(ctx, newArgs)
2936
}
3037

3138
hc := interp.HandlerCtx(ctx)

pkg/devspace/pipeline/engine/basichandler/handler.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ import (
1414
"time"
1515
)
1616

17+
func init() {
18+
for k := range BasicCommands {
19+
enginecommands.XArgsFocusCommands[k] = true
20+
}
21+
for k := range OverwriteCommands {
22+
enginecommands.XArgsFocusCommands[k] = true
23+
}
24+
}
25+
1726
// BasicCommands are extra commands DevSpace provides within the shell or are common
1827
// commands that might not be available locally for example in windows systems.
1928
var BasicCommands = map[string]func(ctx context.Context, args []string) error{

pkg/devspace/pipeline/engine/pipelinehandler/handler.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ func init() {
9393
return interp.NewExitStatus(1)
9494
}
9595
}
96+
for k := range PipelineCommands {
97+
basichandlercommands.XArgsFocusCommands[k] = true
98+
}
9699
}
97100

98101
func NewPipelineExecHandler(ctx devspacecontext.Context, stdout, stderr io.Writer, pipeline types.Pipeline) enginetypes.ExecHandler {

0 commit comments

Comments
 (0)