Skip to content

Read Quoting the Write Guard's Quote-Keeping Lex Cannot Align #3084

Closed

Description

@ptr727

Context

Found by the local review of the pull request closing #3006. Both items come from the quote-keeping lex, _quote_kept_tokens, which the run-time word checks for a merge and a commit read. They were confirmed with classify probes on constructed commands.

Where the Quote-Keeping Lex Is Unavailable, Words Are Misread

_quote_kept_tokens lexes with non-POSIX shlex, which does not model a quote that opens mid-word, adjacent quoted spans, a backslash escape, or an apostrophe in a comment. Where it cannot align, it returns None, and two things follow.

  • A quoted option value is denied. _split_free falls back to the unquoted token, so gh pr merge 1 --body "$BODY"; echo a"b c" is denied naming $BODY. So is the same merge beside echo 'it''s', echo a\ b, or a trailing # it's. The deny says only a quoted option value may be a run-time word, which is the form the command used. The READMEs state the exception without this condition.
  • The command's end is misread. With no quote mask, _region_end reads past a ; that _shell_tokens fused into a word. So gh pr merge 1; echo $'a\'b' is denied, naming the echo's word as one of the merge's. git commit -m x; echo $'a\'b' is denied the same way by _rewritten_git_words.

Each of these is a false deny, never a false allow.

Possible Direction

Lex with a reader that models POSIX quoting, so the mask and the quote-kept tokens are available for every command the shell itself accepts. Until then, say in the deny and the READMEs that a quoted value is accepted only where the guard can read the command's quoting, naming the spellings above.

Activity

  1. added
    introduced
    script
    on Oct 15, 2026
  2. ptr727 commented on Oct 23, 2026

    @ptr727
    OwnerAuthor

    Closed as out of the write guard's scope under the maintainer's decision (ptr727, 2026-10-23) on #3391, item 1. The guard bounds a good-faith agent's mistake rather than an adversary, so a parse gap reached only by a command shape no agent plausibly types in a coding session is closed rather than fixed, and the guard's own growth is a cost each later review pays again. The scope statement lands in the guard's docstring and README under #3391. Reopen only with a command a session actually produced.

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

    introducedscript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions