Skip to content

End the Write Guard's Allexport Reading at an Unconditional set +a #3395

Closed

Description

@ptr727

The write guard's _export_events keeps allexport on once a set -a or set -o allexport has been read, so a later set +a does not end it. Constructed case: in set -a; set +a; GIT_CONFIG_COUNT=1; GIT_CONFIG_KEY_0=core.hooksPath; GIT_CONFIG_VALUE_0=/example/hooks; git commit -m msg, the config assignments are not exported, yet the guard reads them as exported and denies. origin/main allows it. The reading is conservative: it fails closed.

A first attempt to model the off switch (apply each set flag in order) allowed what develop denies, so it was dropped. Review of that attempt found these must stay denied: a set +a inside a function never called, a subshell, a pipeline, a background job, a branch (if false; then set +a; fi, false && set +a), a loop or function rerun that runs a set -a again, and words after -- or the first non-option word, which set does not read as options. A cluster holding o such as -eo allexport or -ao pipefail must still turn it on.

Fix direction: honor +a and +o allexport only for a top-level unconditional set with no subshell, pipeline, background, function, or loop around it, and only where _reruns is false. Add the denied shapes above as self-test cases beside the allow control.

Introduced by the allexport reading in the write guard, found by Copilot on promotion pull request 3393.

Activity

  1. added
    agents
    gate
    introduced
    on Oct 23, 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

    agentsgateintroduced

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions