From 22fd74846de5226165ba1f57bc1a9fb7f82e5245 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Fri, 1 Jan 2021 17:32:42 -0300 Subject: [PATCH] Use `interp.Params("-e")` intead of running "set -e" manually This is an improvement for ac8e3441736a9cab4c64f8feb67619bfda17a08a --- internal/execext/exec.go | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/internal/execext/exec.go b/internal/execext/exec.go index 6ac9b1ad..851fd2bd 100644 --- a/internal/execext/exec.go +++ b/internal/execext/exec.go @@ -27,18 +27,8 @@ type RunCommandOptions struct { var ( // ErrNilOptions is returned when a nil options is given ErrNilOptions = errors.New("execext: nil options given") - - setMinusE *syntax.File ) -func init() { - var err error - setMinusE, err = syntax.NewParser().Parse(strings.NewReader("set -e"), "") - if err != nil { - panic(err) - } -} - // RunCommand runs a shell command func RunCommand(ctx context.Context, opts *RunCommandOptions) error { if opts == nil { @@ -56,6 +46,7 @@ func RunCommand(ctx context.Context, opts *RunCommandOptions) error { } r, err := interp.New( + interp.Params("-e"), interp.Dir(opts.Dir), interp.Env(expand.ListEnviron(environ...)), interp.OpenHandler(openHandler), @@ -64,9 +55,6 @@ func RunCommand(ctx context.Context, opts *RunCommandOptions) error { if err != nil { return err } - if err = r.Run(ctx, setMinusE); err != nil { - return err - } return r.Run(ctx, p) }