Skip to content

Reading from files in while loops broken since 3.39.0 #1965

@andrewimeson

Description

@andrewimeson

Description

This was originally reported in #1865 , but it looks like it got closed prematurely. The issue was reproducible in the upstream mvdan/sh interpreter (see mvdan/sh#1099) and was fixed at least as far as the simple case of directly invoking the interpreter goes. The issue still persists in Task, despite Task updating to the v3.10.0 release of Sh with the fix (#1874).

This first broke in Task v3.39.0, and is still broken in v3.40.1

Version

v3.40.1

Operating system

macOS

Experiments Enabled

No response

Example Taskfile

---
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: 3
tasks:
  test:
    desc: Reproduce issue
    cmds:
      - |
        echo hi
        $_ --version

        # Works
      - |
        echo "hi pipe" | while read -r line; do
            echo "$line"
        done

        # Hangs
      - |
        echo "hi file" > hi.txt

        while read -r line; do
            echo "$line"
        done < hi.txt

        echo "done"

  clean:
    desc: Clean files
    cmds:
      - |
        rm hi.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    dep: mvdan/shIssues related to the upstream interpreter used by Task.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions