Skip to content

Split an Operator After an Escaped Backslash the Way Bash Does #2313

Closed as not planned

Description

@ptr727

Problem

The guard's tokenizer in host-setup/agent-safety/claude/gh-write-guard.py reads an escaped backslash followed by an operator as one word, so a shell wrapper glued to that operator is never seen as a command. Constructed example, allowed although bash runs the loop with no bound:

timeout 900 true \;bash -c 'while true; do sleep 1; done'

Bash reads \\ as a literal backslash argument to true and the ; as a real separator, so bash -c runs on its own. The tokenizer yields a single ;bash token instead, and the wait-loop check never reaches the wrapper. It may share a cause with #1959, which covers shlex pairing quotes differently from bash, but this shape holds no quote.

Done looks like

The tokenizer splits an unescaped operator after an escaped backslash the way bash does, or the check reads such a token as no bound, with a self-test row for the shape above.

Found by a local strict review pass on #2117. It predates that pull request.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions