Skip to content

fix(repl): make sudo/pipeline work with built-in commands on Windows - #34

Merged
caomengxuan666 merged 1 commit into
unixwin:mainfrom
arookieofc:feature/winux-shell-integration
Mar 22, 2026
Merged

caomengxuan666 merged 1 commit into
unixwin:mainfrom
arookieofc:feature/winux-shell-integration

Conversation

@arookieofc

Copy link
Copy Markdown
Member

Summary

This PR fixes Windows REPL compatibility issues where built-in commands failed under:

  • native Windows sudo (for example: sudo lsof -p 6424)
  • shell pipelines (for example: lsof | grep ...)

Root Cause

REPL fallback sends shell-meta commands (|, >, <, &) to cmd /c.
In that path, built-in commands like lsof were treated as external programs and could fail if no lsof.exe link/binary existed.

Changes

  • Added sudo rewrite:
    • sudo <builtin> ... -> sudo <absolute winuxcmd.exe> <builtin> ...
  • Added pipeline builtin rewrite:
    • each pipeline segment starting with a WinuxCmd built-in is rewritten to:
      <absolute winuxcmd.exe> <segment>
  • Kept fast internal dispatch unchanged for regular single commands.
  • Adjusted executable path quoting to avoid cmd parsing issues in piped commands.

Behavior After

  • sudo lsof ... works even without standalone lsof.exe.
  • lsof | grep ... works in REPL because lsof is executed via winuxcmd.exe lsof.
  • Existing non-pipeline/non-sudo command behavior is unchanged.

Notes

  • grep in this project uses regex by default.
  • For Windows paths, prefer fixed-string search:
    • grep -F "D:\\.codex\\"

- rewrite `sudo <builtin> ...` to `sudo <winuxcmd.exe> <builtin> ...`
- rewrite pipeline segments that start with built-ins to `<winuxcmd.exe> <cmd>`
- preserve normal dispatch for single non-shell-meta commands
- fix executable path quoting strategy for cmd pipeline compatibility
@caomengxuan666
caomengxuan666 merged commit 064226f into unixwin:main Mar 22, 2026
4 checks passed
caomengxuan666 added a commit that referenced this pull request Mar 24, 2026
…l-integration

fix(repl): make sudo/pipeline work with built-in commands on Windows
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.

2 participants