task
task copied to clipboard
Respect ignore_error when calling another task from a command
- Task version: master
- OS: Linux
When calling task other
with the following Taskfiles:
this works, the error is ignored
version: "3"
tasks:
bad:
cmds:
- exit 1
other:
cmds:
- cmd: task bad
ignore_error: true
- echo hello
this does not work, nothing is printed
version: "3"
tasks:
bad:
cmds:
- exit 1
other:
cmds:
- task: bad
ignore_error: true
- echo hello
Hi @shilangyu, thanks for opening this issue!
This doesn't work because it was not originally intended to work like this. It may makes sense to respect that, though...
@andreynering I stumbled upon this exact problem. To me this is a bug, not an enhancement, for the following reason: adding ignore_error to a task has the effect that the task is silently skipped and the user doesn't even understand what is going on :-) If it was not intended to work like this, Task should fail reporting a syntax error I think...
EDIT Ah sorry I take it back; with Task v3.3.0 I do get what I expect:
$ task other
task: exit 1
task: Failed to run task "other": task: Failed to run task "bad": exit status 1
I will create a separate ticket for the problem I stumbled upon
My 2c is that ignore_error
should work the same way when invoking another task. In my case, the workaround I came up with is to create another task that includes ignore_error: true
and add an -ignore-error
prefix to its name, so:
version: "3"
tasks:
bad:
cmds:
- exit 1
bad-ignore-error:
ignore_error: true
cmds:
- exit 1
other:
cmds:
- task: bad-ignore-error
- echo hello
not ideal but gets the job done