Pane icon indicating copy to clipboard operation
Pane copied to clipboard

Windows executable lookup: limit PATHEXT to .com/.exe/.bat/.cmd

Open parsakhaz opened this issue 2 weeks ago • 2 comments

Follow-up from re-review of #1430. findExecutableInPath now tries every PATHEXT extension before the bare name. PATHEXT also lists .vbs, .js, .wsf and .msc, which hostCommand doesn't wrap. If a PATH folder holding only codex.js comes before the folder holding codex.cmd, the lookup now returns the .js file. This layout is rare. Fix: try only .com, .exe, .bat and .cmd. Where: main/src/utils/shellPath.ts:~500.

parsakhaz avatar Nov 16 '26 17:11 parsakhaz

Hey, I'll take this one. In findExecutableInPath (shellPath.ts) the PATHEXT loop tries every extension, so a codex.js in an earlier PATH folder wins over codex.cmd and hostCommand can't launch it. Plan is to only try .com/.exe/.bat/.cmd, keeping PATHEXT's order between them, then the bare name, with tests for that exact .js-before-.cmd layout. Already have it on a branch, PR shortly.

ilijachrchev avatar Nov 16 '26 21:11 ilijachrchev

PR's up: #1452. Lookup only tries the launchable extensions now, and the tests cover the .js-before-.cmd PATH layout.

ilijachrchev avatar Nov 16 '26 21:11 ilijachrchev