Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sdemura opened this issue Oct 15, 2024 · 0 comments
Open

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

sdemura opened this issue Oct 15, 2024 · 0 comments
Labels
state: needs triage Waiting to be triaged by a maintainer.

Comments

@sdemura
Copy link

sdemura commented Oct 15, 2024

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:
@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Oct 15, 2024
@sdemura sdemura changed the title mvdan.cc/sh/v3 v3.9.0 breaks mvdan.cc/sh/v3 v3.9.0 breaks reading from file redirection Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: needs triage Waiting to be triaged by a maintainer.
Projects
None yet
Development

No branches or pull requests

2 participants