Summary
The shell escape feature (#566) uses cmd /c on Windows, which correctly handles .bat and .cmd files. However, PowerShell scripts (.ps1) do not work with cmd /c — they require powershell -File or pwsh -File.
Current behavior
[myshell]$ !deploy.ps1
'deploy.ps1' is not recognized as an internal or external command
Expected behavior
[myshell]$ !deploy.ps1
Deploying to production...
Done.
Proposed approach
In executeNativeCommand(), detect the file extension of the first token:
.bat / .cmd / no extension / built-in commands -> cmd /c command (current behavior)
.ps1 -> powershell -File script.ps1 args... or pwsh -File script.ps1 args...
Auto-detect whether pwsh (PowerShell Core, cross-platform) or powershell (Windows PowerShell) is available.
Alternative
Instead of auto-detecting, add a setting for the shell command:
SettingsBuilder.builder()
.shellEscapeCommand("pwsh", "-Command") // override default sh/cmd
This would also support using bash on Windows (via WSL or Git Bash).
Context
Follow-up to #566 (shell escape via ! prefix).
Summary
The shell escape feature (#566) uses
cmd /con Windows, which correctly handles.batand.cmdfiles. However, PowerShell scripts (.ps1) do not work withcmd /c— they requirepowershell -Fileorpwsh -File.Current behavior
Expected behavior
Proposed approach
In
executeNativeCommand(), detect the file extension of the first token:.bat/.cmd/ no extension / built-in commands ->cmd /c command(current behavior).ps1->powershell -File script.ps1 args...orpwsh -File script.ps1 args...Auto-detect whether
pwsh(PowerShell Core, cross-platform) orpowershell(Windows PowerShell) is available.Alternative
Instead of auto-detecting, add a setting for the shell command:
This would also support using
bashon Windows (via WSL or Git Bash).Context
Follow-up to #566 (shell escape via
!prefix).