Skip to content

Commit 0485d3f

Browse files
author
Martin Vogel
committed
fix(cli): probe Windows PATHEXT variants in find_in_path (#221)
Agent CLIs on Windows are installed as .cmd/.ps1/.exe shims (e.g. opencode via mise/npm), but find_in_path only probed the bare name, so they weren't detected. Try .exe/.cmd/.bat/.ps1 per PATH entry on Windows. Relates to #221 (opencode not detected). The install-time taskkill 'eq' error from the same report is addressed separately — cbm_kill_other_instances now uses _spawnvp with an argv array rather than a shell string.
1 parent d198403 commit 0485d3f

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎src/cli/cli.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,19 @@ static bool find_in_path(const char *name, char *out, size_t out_sz) {
262262
if (is_executable(out)) {
263263
return true;
264264
}
265+
#ifdef _WIN32
266+
/* On Windows executables carry an extension (PATHEXT). A CLI like
267+
* opencode is often installed as a .cmd / .ps1 / .exe shim (e.g. via
268+
* mise or npm), so the bare-name probe above misses it (#221). Try the
269+
* common executable extensions before moving to the next PATH entry. */
270+
static const char *const win_exts[] = {".exe", ".cmd", ".bat", ".ps1", NULL};
271+
for (int i = 0; win_exts[i]; i++) {
272+
snprintf(out, out_sz, "%s/%s%s", dir, name, win_exts[i]);
273+
if (is_executable(out)) {
274+
return true;
275+
}
276+
}
277+
#endif
265278
dir = strtok_r(NULL, PATH_DELIM, &saveptr);
266279
}
267280
return false;

0 commit comments

Comments
 (0)