Skip to content

emrg: enforce CRLF for Windows .cmd/.ps1 + truthful stop-git failure (rant 2026-08-12T12:30:41) - #701

Merged
argszero merged 1 commit into
masterfrom
feature/cmd-crlf-installer-exit-fix
Aug 12, 2026
Merged

emrg: enforce CRLF for Windows .cmd/.ps1 + truthful stop-git failure (rant 2026-08-12T12:30:41)#701
argszero merged 1 commit into
masterfrom
feature/cmd-crlf-installer-exit-fix

Conversation

@argszero

Copy link
Copy Markdown
Owner

Root cause of the 0.2.25/0.2.26/0.2.27 Windows installer 'exit code 1' series (host 2026-08-12 step-by-step diagnosis):

Main root cause — LF-only .cmd files are misparsed by cmd.exe

  • All tracked bin/*.cmd and stop-git.ps1 were LF-only in the repo. cmd.exe joins the whole file serially (@echo off ignored, PATH collisions produce arbitrary errors, non-zero exit) → PrepareToInstall's stop-emrg.cmd run aborted with exit code 1. The 0.2.26 'escape bug' and 0.2.27 'verify misjudgement' were both symptoms of this.
  • Fix: new .gitattributes*.cmd, *.bat, *.ps1 text eol=crlf → git checks out CRLF on every platform (blobs stay LF-canonical; verified git ls-files --eol = i/lf w/crlf).
  • New guard test tests/test_cmd_crlf.py (works on every pytest runner incl. CI): every tracked *.cmd/.bat/.ps1 must have zero bare-LF lines — a future PR adding a LF-only .cmd fails CI instead of the installer.

Secondary — stop-git.ps1 truthful failure (spec B)

  • Survivor check already re-enumerates (fresh snapshot); now it names survivors (still running: <name> (pid N)) before exiting 1, so the installer shows a useful message instead of a silent bogus exit=0 when an admin-owned sh/vim cannot be killed.
  • Existing test updated to assert the new form.

Verification: pytest 729 → 730 (new CRLF guard + updated stop-git assertion), import + CLI green, doc counts synced. The installed .cmd files come from a fresh CI checkout → CRLF → 0.2.28 installer should no longer hit 'stop-emrg.cmd exit code 1'.

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 20260812-123914 (reviewer: argszero)

Reviewed the full diff: .gitattributes CRLF enforcement (.cmd/.bat/*.ps1 text eol=crlf) is the correct root-cause fix for the LF-misparse installer series; the new CRLF guard test (zero bare-LF lines across all tracked Windows scripts) runs on every pytest runner incl. CI; stop-git.ps1 truthful-failure reporting (names survivors before exit 1, never silent bogus exit=0); updated assertion + doc count synced. Verified git ls-files --eol = i/lf w/crlf for all four scripts.

CI PASS (31563862915) — actionlint gate + doc-count guard + full pytest green. No issues found.

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 20260812-1240 (reviewer: argszero)

Reviewed the full diff (.gitattributes + guard test + stop-git.ps1 + test update):

  • .gitattributes: .cmd/.bat/*.ps1 text eol=crlf — blobs stay LF-canonical, checkout is CRLF on every platform. Verified via fresh clone: all 4 tracked scripts show i/lf w/crlf.
  • Guard test validated in BOTH states: fresh checkout (CI-equivalent) → PASSES; injected LF-only file → discriminator (crlf != lf) correctly flags it. A future LF-only .cmd fails CI instead of the installer.
  • stop-git.ps1 truthful failure: survivors named ('still running: name (pid N)') + exit 1; exit 0 only when clean — no silent bogus success. test_installer_stop.py updated to assert the new form; 5 tests pass.
  • Agent.md count synced (729 → 730).

One operational note (not a blocker): local checkouts that predate .gitattributes keep stale LF .cmd files (git doesn't rewrite unchanged blobs) — run git add --renormalize . once after merging so the guard passes locally. CI is unaffected (fresh checkout).

No issues found.

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 20260812-124221 (reviewer: argszero)

3rd consecutive LGTM (123914 + 1240 parallel + this cycle). Code unchanged since full review in cycle 123914; CI PASS (31563862915). Merge condition satisfied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant