Skip to content

mvdan.cc/sh/v3 v3.9.0 breaks reading from file redirection #1865

@sdemura

Description

@sdemura

Problem: Running into mvdan/sh#1099, see https://github.com/go-task/task/blob/v3.39.2/go.mod#L26

Request: mvdan/sh should be downgraded to 3.8.0

Example taskfile:

version: "3"

tasks:
  embedded-hang:
    cmds:
      - cmd: |
          set -x

          while read -r line; do
              echo "$line"
          done < <(echo "hi file substitution")

          echo done

  use-script:
    cmds:
      - cmd: |
          cat <<EOF> read.sh
          #!/bin/bash

          set -x

          while read -r line; do
              echo "$line"
          done < <(echo "hi file substitution")

          echo done
          EOF

          chmod +x read.sh

          ./read.sh

Hangs when using gosh:

❯ task embedded-hang
task: [embedded-hang] set -x

while read -r line; do
    echo "$line"
done < <(echo "hi file substitution")

echo done

+ echo 'hi file substitution'
+ read '-r line'
+ echo 'hi file substitution'
hi file substitution
+ read '-r line'
^Ctask: Signal received: "interrupt"
^Ctask: Signal received: "interrupt"
^Ctask: Signal received for the third time: "interrupt". Forcing shutdown
/private/tmp/task took 4s

Sanity check, writing same script to disk and running it directly works as expected

❯ task use-script
task: [use-script] cat <<EOF> read.sh
#!/bin/bash

set -x

while read -r line; do
    echo "$line"
done < <(echo "hi file substitution")

echo done
EOF

chmod +x read.sh

./read.sh

+ read -r line
++ echo 'hi file substitution'
+ echo ''

+ read -r line
+ echo done
done
  • Task version: v3.39.2
  • Operating system: macos
  • Experiments enabled:

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions