Skip to content

envmanifest: "export -n NAME" is recorded as exporting NAME #9157

Open

Description

@jflowers

What happens

The shell export collector in internal/envmanifest/shellexports.go skips every export argument that starts with -. For export -n FOO, it skips -n and then records FOO as exported. In Bash, -n removes the export attribute, so the collector reports the opposite of what the script does. shellexports_test.go currently expects this result.

What should happen

A name that a script un-exports with export -n isn't reported as exported, including when it was exported earlier in the same script (export FOO=bar; export -n FOO).

Context

Found by the review bot on #8679. Nothing in the repo uses export -n today, so the generated sandbox env contract isn't affected yet. It would only become wrong if a launch script starts using -n.

Activity

  1. fullsend-ai-triage commented on Nov 6, 2026

    @fullsend-ai-triage

    🤖 Finished Triage · ✅ Success · Started 2:05 PM UTC · Completed 2:07 PM UTC

    Commit: 1ae0595 · View workflow run →

    Runtime: claude · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.18

  2. added
    ready-to-code
    on Nov 6, 2026
  3. fullsend-ai-triage commented on Nov 6, 2026

    @fullsend-ai-triage

    Confirmed in the code: the export branch of collectFromCommand skips every dash-prefixed argument without interpreting it, and the collector's result set is add-only, so it can't retract a name exported earlier. The existing export flags are skipped test locks in the incorrect result.

    Fix notes

    • Interpret -n (including combined short flags, and -- ending options) as un-export mode, removing the operands from the exported set instead of adding them.
    • Un-export needs to be order-aware so export FOO=bar; export -n FOO yields nothing. Take care not to retract names recorded from prefix assignments (FOO=1 cmd), which only affect that child process. Tracking those separately from shell-level exports avoids the problem.
    • Update the ExportedNames doc comment and the test expectation.

    Proposed test cases

    export -n FOO                    -> []
    export FOO=bar; export -n FOO    -> []
    export -n FOO; export FOO=1      -> [FOO]
    export A B; export -n A          -> [B]
    export -p BAR                    -> [BAR]
    sh -c 'export X=1; export -n X'  -> []
    

    Severity is low: nothing in the repo uses export -n today, so the generated sandbox env contract isn't currently affected. No open PR addresses this, and no CI/workflow changes are needed.


    Next steps:

    • /fs-code — agent creates a PR to implement this issue
    • /fs-code <your instruction> — agent implements with your specific guidance
  4. fullsend-ai-coder commented on Nov 6, 2026

    @fullsend-ai-coder
    Contributor

    🤖 Finished Code · ✅ Success · Started 2:09 PM UTC · Completed 2:22 PM UTC

    Commit: 1ae0595 · View workflow run →

    Runtime: claude · Model: opus → claude-opus-5-5 · Effort: high · Cost: $1.00

  5. added 5 commits that reference this issue on Nov 6, 2026
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

    bugready-to-code

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions