Skip to content

Read a cd or pushd Word as the Builtin Only in Command Position in the Write Guard #3319

Closed

Description

@ptr727

Problem

Rule 6 of the write guard scans every token named cd, pushd, popd, or chdir as that builtin, wherever the token sits. _cd_dot_dot does this, and so does the directory-stack check added on the pull request closing #3048. Since that pull request reads a bare pushd or popd as a move to a stack directory, the word pushd or popd ending a command now fails closed on any later mutating git command in the same call. That holds even where the word is only an argument.

This is an over-denial, low in likelihood, and it fails closed. It was found by the local review on that pull request. Per that lane's rule it is filed rather than narrowed.

Reproduction (constructed commands)

Classify each of these in a linked worktree session:

  • which popd; git add x
  • git commit -m popd

Each is denied, naming a bare pushd or popd. Neither moves the shell.

Possible Direction

Read a cd/pushd/popd/chdir word as the builtin only in command position. The guard already tests that for other rules (_runs_as_command). Move both _cd_dot_dot and the directory-stack scan onto it, since they share _cd_argument.

🤖 Generated with Claude Code

Activity

  1. added
    bug
    script
    on Oct 21, 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

    bugscript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions