Skip to content

Add wslc shell script for WSL interop#40142

Draft
benhillis wants to merge 2 commits intofeature/wsl-for-appsfrom
user/benhill/wslc_alias
Draft

Add wslc shell script for WSL interop#40142
benhillis wants to merge 2 commits intofeature/wsl-for-appsfrom
user/benhill/wslc_alias

Conversation

@benhillis
Copy link
Copy Markdown
Member

Summary

Add a shell script that allows WSL users to run wslc instead of wslc.exe from within a WSL distribution, similar to how VS Code ships a code script alongside code.exe.

Changes

  • src/windows/wslc/wslc — New shell script that resolves wslc.exe relative to its own location and forwards all arguments
  • src/windows/wslc/.gitattributes — Enforces LF line endings so the script works in WSL
  • msipackage/package.wix.in — Adds the script to the MSI package (installed to Program Files\WSL)
  • msipackage/CMakeLists.txt — Adds the script as a build dependency for the MSI
  • test/windows/SimpleTests.cpp — Adds WslcShellScript smoke test that verifies wslc and wslc.exe produce identical output inside WSL

How it works

Since Program Files\WSL is already on the system PATH (added by the MSI), and WSL appends Windows PATH entries by default, the extensionless wslc script is found automatically when a user types wslc inside a WSL distribution.

@benhillis benhillis requested a review from a team as a code owner April 9, 2026 16:12
Copilot AI review requested due to automatic review settings April 9, 2026 16:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a Windows-installed wslc POSIX shell wrapper so users inside WSL can run wslc (no .exe) and have it forward to the adjacent wslc.exe, and wires it into MSI packaging + a basic smoke test.

Changes:

  • Add src/windows/wslc/wslc wrapper script and enforce LF line endings via .gitattributes.
  • Include the script in the MSI (package.wix.in) and ensure MSI rebuilds when it changes (msipackage/CMakeLists.txt).
  • Add a Windows smoke test validating wslc vs wslc.exe output in WSL.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/windows/SimpleTests.cpp Adds smoke test comparing wslc.exe version vs wslc version output inside WSL.
src/windows/wslc/wslc New shell wrapper that locates wslc.exe next to itself and forwards args.
src/windows/wslc/.gitattributes Forces LF for the wrapper script so it runs correctly under WSL.
msipackage/package.wix.in Adds the wslc script file to the MSI installation payload.
msipackage/CMakeLists.txt Ensures MSI packaging rebuilds when the wrapper script changes.

@ptrivedi
Copy link
Copy Markdown

ptrivedi commented Apr 9, 2026

The thing to be aware of here is that from inside of WSL, when you call wslc.exe run ..., it is going to create a separate VM for the CLI session. We will also have to properly test out and see how port mapping etc. will work in cases like this.

@benhillis
Copy link
Copy Markdown
Member Author

The thing to be aware of here is that from inside of WSL, when you call wslc.exe run ..., it is going to create a separate VM for the CLI session. We will also have to properly test out and see how port mapping etc. will work in cases like this.

Yeah that's valid, but that's an existing issue unrelated to this pr.

WSL_PATH="$(dirname "$(realpath "$0")")"
WSLC_EXE="$WSL_PATH/wslc.exe"

"$WSLC_EXE" "$@"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: We could exec to avoid creating an additional process

@benhillis benhillis marked this pull request as draft April 9, 2026 18:14
@benhillis
Copy link
Copy Markdown
Member Author

Need to close on if this is a good idea or not.

Ben Hillis and others added 2 commits April 9, 2026 11:33
Add a shell script that allows WSL users to run 'wslc' without the
.exe extension, similar to how VS Code ships a 'code' script alongside
code.exe. The script resolves wslc.exe relative to its own location
and forwards all arguments.

- src/windows/wslc/wslc: new shell script
- msipackage: include the script in the MSI package
- test/windows/SimpleTests.cpp: add WslcShellScript smoke test

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address PR feedback: assert that stderr output is identical between
the shell script and direct .exe invocation, fixing unused variable
warnings that would fail MSVC /WX builds.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@benhillis benhillis force-pushed the user/benhill/wslc_alias branch from 79a98a3 to ad0e370 Compare April 9, 2026 18:39
Copilot AI review requested due to automatic review settings April 9, 2026 18:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment on lines +11 to +12
"$WSLC_EXE" "$@"
exit $?
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

The wrapper runs wslc.exe as a child process and then explicitly exit $?. Using exec "$WSLC_EXE" "$@" would replace the shell process with wslc.exe, avoiding an extra process and ensuring signal/exit-code behavior matches the underlying CLI more directly (e.g., Ctrl-C / SIGINT handling).

Suggested change
"$WSLC_EXE" "$@"
exit $?
exec "$WSLC_EXE" "$@"

Copilot uses AI. Check for mistakes.
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.

4 participants