Skip to content

fix(windows):Fixed bash, cmd, powershell, etc routing#8768

Open
burgercrisis wants to merge 15 commits intoanomalyco:devfrom
burgercrisis:bashedbacktothefuture
Open

fix(windows):Fixed bash, cmd, powershell, etc routing#8768
burgercrisis wants to merge 15 commits intoanomalyco:devfrom
burgercrisis:bashedbacktothefuture

Conversation

@burgercrisis
Copy link

@burgercrisis burgercrisis commented Jan 16, 2026

What does this PR do?

Fixes #6488
Fixes very many issues for windows users with how it uses shells.
no cross-shell translation logic; just clean cross-platform compatible shell routing

How did you verify your code works?

Used test scripts in building to verify probably 200+ commands
Verified in app along the way with a suite of commands
% pass on my in-app test suite of 140 commands pre-fix: ~40%
% pass on my in-app test suite of 140 commands post-fix: ~100%

Merged latest stable release 1.1.23 in.
Cleaned repo.
Cleaned related dead code - get_user_shell is now redundant with my upgrades.

Test User and others added 15 commits January 14, 2026 13:16
- Add Shell.getSpawnConfig() to route PowerShell/CMD commands directly to their executables
- Implement delayed expansion for CMD commands with dynamic variables (%, %cd%, %temp%, etc.)
- Fix variable corruption when commands like "cd /d %temp% && echo %cd%" execute through Git Bash
- Add detection helpers: isPowerShellCommand(), isCmdCommand(), hasDynamicEnvVars()
- Update BashTool to use new spawn configuration logic
- Add support for pwsh executable alongside powershell in command detection
- Implement debug/verbose flag detection and preference variable injection
- Add processPowerShellOutput function to improve error messages with actionable guidance
- Handle common PowerShell issues: non-existent cmdlets, missing parameters, Get-Credential in non-interactive mode, debug functionality limitations
- Extend timeout for Start-Job commands to prevent premature termination
…ndling

- Implement special handling for CMD echo commands and commands with pipes/quotes
- Add Windows-to-Unix command translation with helpful error messages
- Add comprehensive PowerShell command detection and output processing
- Add detailed logging for CMD command execution
- Add extensive test coverage for Windows command scenarios
…rting

- Extend timeout for all PowerShell job cmdlets to 10 minutes
- Capture and set proper exit codes for timeout and abort scenarios
- Remove problematic Get-Credential test that caused application freezing
- Track exit code from process for accurate metadata reporting
… executable selection

- Fix path normalization for Windows Git Bash paths by converting /c/Users/ to C:\Users\ format
- Replace realpath command with Node.js path.resolve for better cross-platform compatibility
- Add fallback logic for PowerShell executable selection (pwsh.exe vs powershell.exe)
- Remove redundant cd command translation in Windows command mapping
- Update test case to use non-existent path to verify error handling
…ogic however; this works very well but seems backwords so next commits will see if there is a truly better working solution
- Add Shell.isCmdBuiltin() function to detect CMD builtins (dir, copy, del, etc.)
- Route bare CMD commands to cmd.exe instead of throwing errors
- Remove Windows-to-Unix command translation layer
- Update bash tool to automatically wrap detected CMD builtins
- Add comprehensive test coverage for bare CMD command execution
- Enhance shell fallback logic on Windows to find bash via PATH first, then explicit flag, then Git locations
- Add detailed debug logging for shell fallback, PowerShell detection, and CMD builtin checks
- Improve CMD builtin detection to handle explicit "cmd /c" commands and pipes properly
- Expand variable expansion in convertToDelayedExpansion to include more CMD variables
- Reorder command checks to handle PowerShell before CMD builtins for better parsing
- Remove all debug console.log statements guarded by Flag.OPENCODE_DEBUG_SHELL
- Clean up logging from bash path detection, PowerShell parsing, and CMD builtin checks
- Maintain functional behavior while reducing noise and improving code cleanliness
- This change removes verbose debug output that was only active when OPENCODE_DEBUG_SHELL was set, making the code cleaner and easier to read without affecting any runtime behavior.
…most of the tests hopefully wont be needed again, I might try to make a test file later that handles this without being quite as atomic)
…entirely so there should be no dead code remnants of the past system left

refactor(cli): simplify shell command construction for non-Windows platforms

- Removed manual shell detection and sidecar path resolution logic
- Replaced shell command construction with direct sidecar invocation using Tauri's built-in sidecar API
- Streamlined environment variable setup and argument passing
- Eliminated unnecessary shell wrapper and argument formatting complexity
- Improved code maintainability and reduced potential error points in CLI command creation
@github-actions
Copy link
Contributor

Hey! Your PR title Feat/fix: Fixed bash, cmd, powershell, etc routing doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@burgercrisis burgercrisis changed the title Feat/fix: Fixed bash, cmd, powershell, etc routing fix/feat (app):Fixed bash, cmd, powershell, etc routing Jan 17, 2026
@burgercrisis burgercrisis changed the title fix/feat (app):Fixed bash, cmd, powershell, etc routing fix(windows):Fixed bash, cmd, powershell, etc routing Jan 19, 2026
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

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.

Bash Fork Issues - Investigation Included

2 participants