openai / openai/codex

codex exec background task rewrote an existing pre-commit hook shebang while asked to "preserve" it

Open
#45,025 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug CLI exec model-behavior windows-os
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

Summary

Asked a Codex background task (codex exec --json, invoked via the Claude Code codex-openai-codex plugin) to add a small delegated call to an existing git pre-commit hook, explicitly instructing it to insert the new block right after the shebang line and leave everything else untouched. In 2 of 7 repositories, the existing hook was a pre-commit (https://pre-commit.com) generated script starting with #!/usr/bin/env bash. After Codex's edit, the file's first line had become #!/bin/sh instead of the original #!/usr/bin/env bash — the shebang itself was altered even though the instruction was to insert after it and preserve the rest.

Reproduction sketch

  1. Start from a file:
    #!/usr/bin/env bash
    # File generated by pre-commit: https://pre-commit.com
    ...
    
  2. Prompt: "insert this block right after the shebang line, do not touch anything else":
    # MARKER:START
    ...
    # MARKER:END
    
  3. Expected: line 1 stays #!/usr/bin/env bash, block inserted as line 2.
  4. Observed: line 1 became #!/bin/sh.

I don't have the exact prompt/transcript to share publicly (it was proxied through another agent's orchestration), but wanted to flag the behavior in case it's a known class of issue with shebang-adjacent edits.

Secondary observation (same run)

In the same task, a loop over multiple repos calling attrib.exe (Windows) consumed the loop's stdin, causing only the first repo's target folder to be processed per iteration — the agent noticed this itself mid-task and redid the affected repos. Not filing this as a primary bug (looks like a known bash/Windows-tool stdin-consumption gotcha), just noting it happened in the same session in case it's useful context.

Environment

  • Windows 11, Git Bash, codex exec --json --sandbox workspace-write via the Claude Code plugin codex-openai-codex

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the edit with codex exec --json --sandbox workspace-write in Git Bash, using the supplied pre-commit example and insertion instruction. Compare the original and edited shebangs across repositories; done means inserting the block after the shebang without changing that line or other existing content.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, git, rust
Domain
cli, devtools, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.