Skip to content

Negated commands exiting with incorrect exit code #2645

@amancevice

Description

@amancevice

Description

Given the following Taskfile:

---
version: 3
tasks:
  example:
    status:
      - "! which badcommand"
    cmds:
      - echo running task

I would expect the example task to NOT run, given that ! which badcommand will surely exit 0. However, Task is reporting that the status command is exiting non-zero and executes the task:

$ task example -v
task: "example" started
task: status command ! which badcommand exited non-zero: exit status 1
task: [example] echo runnning task
runnning task
task: "example" finished

The workaround is to use bash -c "! which badcommand" but I think this is suboptimal.

Version

3.46.4

Operating system

macos v26.2

Experiments Enabled

No response

Example Taskfile

---
version: 3
tasks:
  example:
    status:
      - "! which badcommand"
    cmds:
      - echo running task

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions