Skip to content

fix: read updated shell shim paths - #137

Open
martinrrm wants to merge 1 commit into
mainfrom
fix/read-basedir-win-shims
Open

fix: read updated shell shim paths#137
martinrrm wants to merge 1 commit into
mainfrom
fix/read-basedir-win-shims

Conversation

@martinrrm

@martinrrm martinrrm commented Aug 12, 2026

Copy link
Copy Markdown

Summary

Update the POSIX shell-shim parser to recognize the path form emitted by current versions of cmd-shim.

cmd-shim@9.0.1 added support for invoking Windows executables from WSL. As part of that change, generated shebang-based shell shims began using:

"$basedir_win/<target>" "$@"

instead of:

"$basedir/<target>" "$@"

read-cmd-shim currently recognizes only the original $basedir form. As a result, it reports newer, valid shell shims as ENOTASHIM, even though they were generated by cmd-shim.

This change extends the existing parser to accept the optional, literal _win suffix. It continues to support older shims and returns the same relative target path for both forms.

Why this approach

The parser remains intentionally narrow:

  • only $basedir and $basedir_win are recognized
  • the existing quoting and "$@" structure are still required
  • no shell expressions are evaluated
  • .cmd and PowerShell parsing are unchanged
  • asynchronous and synchronous readers continue to share the same extraction logic

This restores compatibility with current cmd-shim output without changing the public API or the result returned for existing shims.

Compatibility

This is backward-compatible:

  • shims generated by older cmd-shim versions still use $basedir and remain supported
  • shims generated by cmd-shim@9.0.1 and newer can now be read through $basedir_win
  • consumers continue to receive the relative target path
  • invalid or unrelated shell files continue to return ENOTASHIM

Testing

  • all 18 integration tests pass
  • both asynchronous and synchronous shebang shell-shim cases exercise the updated form through the current cmd-shim dependency
  • 100% line, branch, and function coverage
  • ESLint passes
  • CI passes across Linux, macOS, and Windows on every configured Node.js version

Related change

The updated shell-shim form was introduced by npm/cmd-shim#178.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 3ff4d6b3-8027-46d4-9024-3bb9e4fc495c
@martinrrm
martinrrm requested a review from a team as a code owner August 12, 2026 18:33
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