mirror of
https://github.com/go-task/task.git
synced 2024-12-12 10:45:49 +02:00
Use interp.Params("-e")
intead of running "set -e" manually
This is an improvement for ac8e344173
This commit is contained in:
parent
777645888a
commit
22fd74846d
@ -27,18 +27,8 @@ type RunCommandOptions struct {
|
|||||||
var (
|
var (
|
||||||
// ErrNilOptions is returned when a nil options is given
|
// ErrNilOptions is returned when a nil options is given
|
||||||
ErrNilOptions = errors.New("execext: nil options 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
|
// RunCommand runs a shell command
|
||||||
func RunCommand(ctx context.Context, opts *RunCommandOptions) error {
|
func RunCommand(ctx context.Context, opts *RunCommandOptions) error {
|
||||||
if opts == nil {
|
if opts == nil {
|
||||||
@ -56,6 +46,7 @@ func RunCommand(ctx context.Context, opts *RunCommandOptions) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
r, err := interp.New(
|
r, err := interp.New(
|
||||||
|
interp.Params("-e"),
|
||||||
interp.Dir(opts.Dir),
|
interp.Dir(opts.Dir),
|
||||||
interp.Env(expand.ListEnviron(environ...)),
|
interp.Env(expand.ListEnviron(environ...)),
|
||||||
interp.OpenHandler(openHandler),
|
interp.OpenHandler(openHandler),
|
||||||
@ -64,9 +55,6 @@ func RunCommand(ctx context.Context, opts *RunCommandOptions) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err = r.Run(ctx, setMinusE); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return r.Run(ctx, p)
|
return r.Run(ctx, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user