Skip to content

A Command Substitution Inside Double Quotes Hides a Loop When a Line's Quoting Does Not Parse #1843

Closed as not planned

Description

@ptr727

When a line's quoting does not parse, the guard's token fallback cannot follow a double quote that opens inside a command substitution in another double quote. So a loop that bash runs after that point is not seen. This predates the #1635 work: the develop base allows it too.

Reproduction (constructed)

echo "$(echo "'")"; while true; do sleep 5; done; echo "'"  # it's

Both develop and the feature/auto-1635 branch allow this. It is an unbounded wait loop, so requirement 7 should deny it.

Cause

A nested "$( ... "'" ... )" pairs its quotes differently from how shlex pairs them. The apostrophe in the comment makes the whole-command parse fail. The per-line fallback then either splits on whitespace or bails out of comment stripping when it sees $(. In both cases the loop keywords stay fused to their operators.

Done looks like

The command above is denied. A self-test case for it fails when the fix is reverted.

Found by the local strict review on the #1635 fix (handoff #1835).

Activity

  1. added
    bug
    agents
    pre-existing
    on Sep 26, 2026
  2. 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

    agentsbugpre-existing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions