Skip to content

Heredoc edge cases: multiple heredocs, pipe ordering, partial quote delimiters #359

@chaliy

Description

@chaliy

Description

Several heredoc edge cases are not handled correctly.

Scope

  • Multiple heredocs in loop conditions: while cat <<E1 && cat <<E2; do ... done fails to parse
  • Heredoc piped to external command: cat <<EOF | sort produces wrong ordering (heredoc content not piped correctly)
  • Heredoc pipe continuation: cat <<EOF | followed by sort on next line — same pipe issue
  • Partial quote in delimiter: <<'EOF'"2" should combine to delimiter EOF2 with quoting preventing expansion
  • Heredoc followed by multiline dquote: cat <<EOF; echo "two\nthree" on same line does not parse correctly

Repro

Multiple heredocs in condition:

while cat <<E1 && cat <<E2; do cat <<E3; break; done
1
E1
2
E2
3
E3

bashkit: parse error "expected 'do'" — expected output: 1\n2\n3

Heredoc pipe ordering:

cat <<EOF | sort
c
a
b
EOF

bashkit outputs: c\na\nb (unsorted) — expected: a\nb\nc

Test coverage

6 skipped tests in crates/bashkit/tests/spec_cases/bash/heredoc-edge.test.sh (PR #351).

Oils reference: https://github.com/oilshell/oil/blob/master/spec/here-doc.test.sh

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions