go-task / task

A task runner / simpler Make alternative written in Go
https://taskfile.dev
MIT License
11.45k stars 616 forks source link

`set:` options don't apply to dynamically (shell) expanded variables #1901

Open WinkelCode opened 1 week ago

WinkelCode commented 1 week ago
version: "3"

set:
  - pipefail

tasks:
  default:
    vars:
      TESTVAR:
        sh: |-
          false | true
          echo "test"
    cmds:
      - |-
        false | true
        echo "Testing {{.TESTVAR}}"

When pipefail is enabled, the task command fails, but the TESTVAR expansion does not.

$ task -v
task: [REDACTED] Not found - Using alternative (Taskfile.yml)
task: dynamic variable: "false | true\necho \"test\"" result: "test"
task: "default" started
task: [default] false | true
echo "Testing test"
task: Failed to run task "default": exit status 1
trulede commented 15 hours ago

The seems the case, if you compare this: https://github.com/go-task/task/blob/6645a1f34ccc8f9305e137ded2a6493f05543f7d/internal/compiler/compiler.go#L157

to that: https://github.com/go-task/task/blob/6645a1f34ccc8f9305e137ded2a6493f05543f7d/task.go#L388

Perhaps it's reasonable to add PosixOpts and BashOpts to the call at line 157?