Skip to content

A Heredoc Opener Inside a Multi-Line Quote Strips the Commands After It #2111

Closed as not planned

Description

@ptr727

Problem

_heredoc_openers in gh-write-guard.py reads each line of a command on its own. A << sitting inside a double-quoted string that an earlier line opened is therefore read as a heredoc opener. No later line closes its tag, so everything to the end of the command is stripped as body, and a wait loop on those lines is never judged by rule 7.

Reproduce (constructed)

Allowed on develop at 4c9087d and on feature/auto-2059, although the loop has no bound:

git commit -m "Explain
the cat << EOF form"
while [ ! -f /nonexistent ]; do sleep 1; done

Done looks like

The command above is denied, and a self-test row pins it. The opener scan carries quote state across lines, as _context_lex already does for a whole command, rather than lexing a line that sits inside an open quote as if it stood alone. #2062 is the same shape for an arithmetic context an earlier line opened, and one fix may close both.

Found by the local strict review of the #2059 fix.

Activity

  1. ptr727 commented on Oct 8, 2026

    @ptr727
    OwnerAuthor

    Closed: Folded into #1959 per #2517, approved by the maintainer. This is a case of the guard's lexer splitting a command differently from bash, and #1959's single bash-aware scanner fixes the class, with this shape kept as a self-test row there.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions