Skip to content

interp: heredocs get consumed by the first command process executed #1085

Closed

Description

@fungaren

POC:

while read -r FOO BAR; do
  echo $FOO $BAR >/dev/stderr
  cat /not_exist_file
done <<EOF
  AAA BBB
  CCC DDD
EOF
fang@debian:~$ gosh test.sh 
AAA BBB
cat: /not_exist_file: No such file or directory
fang@debian:~$ bash test.sh 
AAA BBB
cat: /not_exist_file: No such file or directory
CCC DDD
cat: /not_exist_file: No such file or directory

Activity

  1. changed the title [-][BUG] misbehavior when process `while read -r; do`[/-] [+][BUG] misbehave `while read -r; do`[/+] on Jul 24, 2024
  2. changed the title [-][BUG] misbehave `while read -r; do`[/-] [+]interp: heredocs get consumed by the first command process executed[/+] on Aug 8, 2024
  3. mvdan commented on Aug 8, 2024

    @mvdan
    Owner

    Thanks for reporting; this is a pretty severe bug actually, and I'm surprised it had not been spotted yet.

  4. added a commit that references this issue on Aug 8, 2024
    980b6fc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions