--- id: "bug-1606" status: "fixed" status_updated: "2026-09-24" status_note: "" component: "build" severity: "unknown" timestamp: "2026-08-20T16:00:00Z" last_seen: "2026-09-19T09:00:00Z" occurrences: 1 files: ["src/tools/test-version-startup-consistency.sh"] tags: ["bash", "grep", "busybox", "sandbox", "portability", "sed", "build-time-versioning"] related: [] legacy: true --- # bug-1606: grep: invalid option -- 'P' (BusyBox usage dump) when a standalone .sh script (run via `bash… ## Description grep: invalid option -- 'P' (BusyBox usage dump) when a standalone .sh script (run via `bash script.sh`, not typed as an inline Bash-tool command) calls `grep -oP '...\K...'` ## Environment _Not recorded (migrated from buglog.json)._ ## Reproduction _Not recorded (migrated from buglog.json)._ ## Root cause This coding-agent harness's interactive shell shadows plain `grep` with a `.bashrc`-sourced shell FUNCTION that shells out to a PCRE-capable (ugrep-backed) binary -- but that function is interactive-shell-only and is NOT inherited by a script invoked as `bash script.sh` (a separate, non-interactive process), which falls back to the real `grep` on PATH: BusyBox in this environment, with no -P/PCRE support at all. `grep -oP '(?<=x)y'` typed directly as a Bash-tool command therefore worked fine, masking the incompatibility until the same call was placed inside a committed script file and run standalone. ## Fix Replaced the grep -oP '"gitCommit":\s*"\K[^"]*' style extraction with POSIX BRE `sed -n 's/.*"gitCommit":[[:space:]]*"\([^"]*\)".*/\1/p'`, which BusyBox sed supports. General rule: any shell script meant to be run standalone (not just typed inline) must assume POSIX-only grep/sed (BRE, -E, -F, -o) -- no -P/PCRE, no lookbehind/\K. ## Verification _Not recorded (migrated from buglog.json)._ ## References _Not recorded (migrated from buglog.json)._