task icon indicating copy to clipboard operation
task copied to clipboard

Regression in error handling

Open Jimver opened this issue 2 months ago • 3 comments

Description

There is a regression when upgrading from 3.44.0 to 3.44.1 where tasks start failing even if they shouldn't.

In the example below all tasks should pass, and they do in 3.44.0 but in 3.44.1 the should-pass task fails.

Note that I need to use /usr/bin/false just using false doesn't work as that doesn't spawn a new process I think, if for some reason you don't have /usr/bin/false you can just write a script that contains exit 1 it has the same effect.

Looking at the diff https://github.com/go-task/task/compare/v3.44.0...v3.44.1, I suspect https://github.com/go-task/task/commit/8a43ca5d8f6025c7fba0d5834d8377d2998ce47c to be the cause.

Version

3.44.1

Operating system

zsh 5.9 (x86_64-apple-darwin23.0)

Experiments Enabled

None

Test results

go-task version should-pass should-pass-fixed
3.44.1 FAIL PASS
3.44.0 PASS PASS

Example Taskfile

version: '3'

tasks:
  should-pass:
    cmds:
      - |
        if /usr/bin/false &>/dev/null; then
          echo "should not reach here"
        fi

  should-pass-fixed:
    cmds:
      - |
        if /usr/bin/false &>/dev/null; then
          echo "should not reach here"
        fi
        true

Jimver avatar Sep 27 '25 15:09 Jimver

The issue might be here: https://github.com/mvdan/sh/issues/1182

Introduced with: https://github.com/go-task/task/blob/72991d4f041e18d925d073e54bc7d264a6d361fb/go.mod#L32

trulede avatar Sep 27 '25 21:09 trulede

Yep that tracks, it's also in the diff from 3.44.0 to 3.44.1: https://github.com/go-task/task/commit/3d3ed0e4039180faed7eed0db79ea64df75b4273

Jimver avatar Sep 28 '25 12:09 Jimver

I tested with the latest mvdan/sh main branch, and it works. So we just need to wait for a new mvdan/sh release.

vmaerten avatar Oct 10 '25 19:10 vmaerten