Skip to content

Windows: command overrides with native absolute paths are corrupted by POSIX backslash tokenization #11375

Closed

Description

@MumuTW

Summary

Custom agent command overrides are parsed by tokenizeCustomCommandTemplate() (src/shared/commit-message-prompt.ts), which applies POSIX shell backslash-escape semantics on every platform. On Windows this silently destroys native absolute paths, since \ is the path separator rather than an escape character.

Reproduction

Enter a normal Windows absolute path as an agent command override in Settings:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

It is tokenized as:

C:WindowsSystem32WindowsPowerShellv1.0powershell.exe

and subsequently reported as not found on PATH.

Reported by @iFwu: #10190 (comment)

Cause

In tokenizeCustomCommandTemplate, the unquoted branch treats \ as an escape and consumes the following character:

if (ch === '\\' && i + 1 < template.length) {
  current += template[i + 1]
  inToken = true
  i += 2
  continue
}

The same treatment applies inside double quotes. The tokenizer is otherwise a reasonable POSIX-style splitter; the problem is that it is platform-unaware.

Workaround

Replace backslashes with forward slashes in the override. This works but is not discoverable, and Windows Settings should accept paths in the form users actually copy from Explorer or where.exe.

Notes on a fix

Backslash handling needs to become platform-aware rather than being removed outright — quoting behaviour is shared with POSIX hosts, and the same override string can target a WSL distro or a remote SSH host, where POSIX semantics remain correct. The platform that matters is the one the command will execute on, not necessarily the one running the UI. Test coverage should include native Windows absolute paths, quoted paths containing spaces, and existing POSIX escape cases.

Impact

Currently blocks the only known working workaround for #11374, since that workaround requires entering an absolute powershell.exe path as an override.

Scope note

Deliberately split out of #10190, which is scoped to Cursor CLI detection. This bug is independent of Cursor and affects any Windows command override.

Activity

  1. bbingz commented on Jul 29, 2026

    @bbingz
    Contributor

    I'd like to take this. I'll add a failing regression for native Windows absolute-path command overrides, then make tokenization execution-platform-aware while preserving the existing POSIX semantics for WSL and SSH targets. I'll keep the change scoped to command parsing and its callers.

  2. added a commit that references this issue on Aug 17, 2026
    6062fc0
  3. added a commit that references this issue on Aug 17, 2026
    71bbab7
  4. added a commit that references this issue on Aug 21, 2026
    7e7e373
  5. added a commit that references this issue on Oct 15, 2026
    e09c26b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions