Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions internal/execext/coreutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
"github.com/go-task/task/v3/internal/env"
)

var useGoCoreUtils bool
var UseGoCoreUtils bool

func init() {
// If TASK_CORE_UTILS is set to either true or false, respect that.
// By default, enable on Windows only.
if v, err := strconv.ParseBool(env.GetTaskEnv("CORE_UTILS")); err == nil {
useGoCoreUtils = v
UseGoCoreUtils = v
} else {
useGoCoreUtils = runtime.GOOS == "windows"
UseGoCoreUtils = runtime.GOOS == "windows"
}
}
2 changes: 1 addition & 1 deletion internal/execext/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func ExpandFields(s string) ([]string, error) {
}

func execHandlers() (handlers []func(next interp.ExecHandlerFunc) interp.ExecHandlerFunc) {
if useGoCoreUtils {
if UseGoCoreUtils {
handlers = append(handlers, coreutils.ExecHandler)
}
return handlers
Expand Down
17 changes: 13 additions & 4 deletions task.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,19 @@ func (e *Executor) runCommand(ctx context.Context, t *ast.Task, call *Call, i in
if closeErr := closer(err); closeErr != nil {
e.Logger.Errf(logger.Red, "task: unable to close writer: %v\n", closeErr)
}
var exitCode interp.ExitStatus
if errors.As(err, &exitCode) && cmd.IgnoreError {
e.Logger.VerboseErrf(logger.Yellow, "task: [%s] command error ignored: %v\n", t.Name(), err)
return nil
if err != nil {
var exitCode interp.ExitStatus
if !errors.As(err, &exitCode) {
if execext.UseGoCoreUtils {
// Convert the err from CoreUtil to an interp.ExitStatus.
e.Logger.Errf(logger.Default, "%v\n", err)
}
err = interp.ExitStatus(1)
}
if cmd.IgnoreError {
e.Logger.VerboseErrf(logger.Yellow, "task: [%s] command error ignored: %v\n", t.Name(), err)
return nil
}
}
return err
default:
Expand Down
Loading