Skip to content

Interrupting Task Does Not Stop Execution of Subsequent Commands #1174

Description

@MoellerMarcel
  • Task version: v3.24.0 (h1:0DKsGTmqYbEaACffm9H2BOm8pTcuSnb5SRUl7TCilQ4=)
  • Operating System: Windows Server 2022 Version 21H2
  • Bash: GNU bash, version 5.2.12(1)-release (x86_64-pc-msys)

First of all, thanks for the great effort of building Task. I'm really looking forward to replacing my Makefiles with Taskfiles!

I ran across an unexpected behavior when interrupting a long-running script. Here's a minimal example:

With the Taskfile:

version: '3'

tasks:
  default:
    cmds:
      - echo "Hello "
      - sleep 5
      - echo "World"

If I interrupt (CTRL + C) the task during sleep, the second echo will still be executed. For example, I get the following output:

$ task
task: [default] echo "Hello "
Hello 
task: [default] sleep 5
task: Signal received: "interrupt"
task: [default] echo "World"
World

Switching from Make, I would expect the interrupt to stop the task (similar to how Task handles errors in commands).

For comparison, a Make script:

hello:
	echo "Hello "
	sleep 5
	echo "World"

will return:

$ make
echo "Hello "
Hello 
sleep 5
make: *** [Makefile:3: hello] Error 512

If this is the intended behavior, I suggest including it in the documentation. While searching for keywords like "interrupt," "kill," or "abort," I could not find anything related in the documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: watcherChanges related to the Taskfile watcher.

    Type

    No fields configured for bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions