Skip to content

Feature/winux shell integration - #36

Merged
caomengxuan666 merged 4 commits into
unixwin:mainfrom
arookieofc:feature/winux-shell-integration
Mar 24, 2026
Merged

caomengxuan666 merged 4 commits into
unixwin:mainfrom
arookieofc:feature/winux-shell-integration

Conversation

@arookieofc

Copy link
Copy Markdown
Member

Summary

This PR improves WinuxCmd REPL shell compatibility by making fallback execution shell-aware and adding PowerShell-native completion support.

What changed

  1. Shell-aware fallback in REPL
  • Detect parent shell on startup (cmd vs powershell/pwsh)
  • Fallback routing:
    • from cmd -> execute via cmd.exe /d /c
    • from PowerShell -> execute via powershell/pwsh -EncodedCommand
  1. PowerShell execution robustness
  • Switch PowerShell fallback from plain -Command string to -EncodedCommand (UTF-16LE Base64)
  • Avoid command echo-only / quoting / pipeline parsing issues in complex cmdlets
  1. Completion improvements
  • Add built-in PowerShell command completions (e.g. Get-Process, Where-Object, etc.)
  • Add built-in PowerShell option completions
  • Only enable PowerShell completions when current REPL shell context is PowerShell
  1. Docs refresh and unification
  • Updated: README.md, README-zh.md
  • Updated: DOCS/en/overview.md, DOCS/zh/overview_zh.md, DOCS/zh/winux_shell_integration_zh.md
  • Added: DOCS/en/winux_shell_integration_en.md
  • Clarified shell distinction, bootstrap snippet, completion env var, and project contribution context

Why

  • Fixes environment confusion between cmd and PowerShell fallback behavior
  • Makes PowerShell cmdlets usable in WinuxCmd REPL when launched from PowerShell
  • Reduces user-facing execution surprises and improves completion relevance

Notes

  • Local binary rebuild was not verified in this environment because cmake/ninja were unavailable in PATH; code and docs are ready for normal CI/local build verification.

- detect parent shell and choose REPL fallback shell (PowerShell or cmd)
- replace PowerShell fallback `-Command` path with `-EncodedCommand` (UTF-16LE + Base64)
- prevent fallback from echoing raw text instead of executing commands
- keep cmd fallback unchanged for cmd-origin sessions
- detect parent shell in REPL startup (cmd vs powershell/pwsh)
- route native fallback by environment:
  - cmd parent -> cmd.exe /d /c
  - powershell parent -> powershell/pwsh -EncodedCommand
- use EncodedCommand for PowerShell fallback to avoid quoting/pipeline breakage
- keep sudo/pipe builtin rewrite compatible with native Windows sudo and mixed pipelines
- add built-in PowerShell command/option completion set
- expose shell-aware completion query APIs and wire them into main REPL completer
- update README / README-zh / DOCS to document:
  - shell-aware fallback behavior
  - PowerShell profile bootstrap snippet
  - completion env var (WINUXCMD_COMPLETION_FILE)
  - project status (many users, limited contributors)
Change WinuxCmd PowerShell fallback startup args from:
  -ExecutionPolicy Bypass
to:
  -ExecutionPolicy RemoteSigned

This avoids overriding user/system execution policy behavior and fixes
profile/script loading issues caused by forced Bypass in child sessions.
@arookieofc

Copy link
Copy Markdown
Member Author

fix: replace PowerShell fallback ExecutionPolicy Bypass with RemoteSigned

Summary

This PR fixes a PowerShell execution policy issue in WinuxCmd fallback mode.

When WinuxCmd falls back to PowerShell for unknown commands, it previously launched with:

-ExecutionPolicy Bypass

That forced process-level policy and could conflict with user expectations around profile/script loading and policy management.

Now it uses:

-ExecutionPolicy RemoteSigned

Changes

  • Updated PowerShell fallback command in:
    • src/Main/main.cpp

Why

  • Avoid forcing Bypass in child PowerShell sessions.
  • Respect safer/default policy behavior.
  • Resolve reported confusion and errors around profile/script execution policy.

Risk

  • Low.
  • Scope is limited to fallback process startup arguments for PowerShell path only.

Testing

  • Verified code diff and repo search:
    • no remaining ExecutionPolicy Bypass usage in source.
  • Full local build was not executed in this environment because cmake is unavailable in PATH.

@caomengxuan666
caomengxuan666 merged commit 8065823 into unixwin:main Mar 24, 2026
4 checks passed
caomengxuan666 added a commit that referenced this pull request Mar 24, 2026
…l-integration

Feature/winux shell integration
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