Skip to content

Here-string inside command substitution mis-parses: $(echo hi <<< y)#tail reports 'unexpected EOF' (GNU: hi#tail) #304

Closed

Description

@caomengxuan666

Found by wt10/contperf while validating the <<< operator fix (rubash#292): after skip_parenthesized_unit correctly treats <<< as one here-string operator, the comsub BODY parse layer still mis-handles the construct — echo $(echo hi <<< y)#tail reports an unexpected-EOF diagnostic on both the pre- and post-fix builds, while WSL GNU Bash 5.3.0 prints hi#tail (the ) followed immediately by # is word text, not a comment — matches the atomic-skip path's reading). Suspect the here-string operand scan inside the comsub body parser. GNU anchor: parse.y read_token redirection-word assembly for r_deblank_string here-strings.

Activity

  1. added
    bug
    on Sep 28, 2026
  2. added a commit that references this issue on Sep 28, 2026
  3. caomengxuan666 commented on Sep 28, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by wt11/lexmix (a5ae33b4, master): the command-substitution collector took the heredoc branch at the FIRST '<' of <<< correctly, but the loop re-entered at the SECOND '<' with a misaligned lookahead, reading <<< y) as a heredoc << with delimiter 'y' and an unterminated body that swallowed )#tail. Both the collector and its copy_command_substitution_heredoc twin now consume <<< as one operator (token_boundary=true, so <<< #x keeps the comment, matching GNU). Anchors: parse.y:3692-3704 read_token '<' case — after << one more char returns LESS_LESS_LESS (:664); ')' followed by '#' is word text (:3630-3643). Verification: 30-case matrix (word-initial/prefix/assignment RHS/quoted/nested/pipes/case/if/multiple substitutions/##/#-) with stdout+stderr byte-identical to WSL GNU 5.3.0; eval/backtick/<<-/<<) edge probes; 12 new regressions; full cli_tests A/B vs base shows zero new failures.

  4. added a commit that references this issue on Sep 29, 2026
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions