---
Problem: filtered bang commands with powershell as `:set shell` doesn't
work. The command structure followed in `make_filter_cmd` is wrong. Try
`:%!sort` on any file to reproduce the bug.
Solution: Fix the command for the powershell in `make_filter_cmd`.
This is not a proper patch. It comes originally from my neovim PR. I
just wanted to see if it would work in vim. It does.
I'm not sending it to vim-dev@googlegroups.com because it's not a proper
patch: I haven't added any tests; haven't changed the docs or the
default config sources. I'm hoping someone in the dev team, who at least
sometimes works with a Windows machine, will take it up and police it.
Here are the configurations for `:set shell=pwsh` this patch worked on:
let &shellcmdflag = "-Command"
let &shellredir = "2>&1 | Out-File -Encoding default %s; exit $LastExitCode"
let &shellpipe = "2>&1 | Out-File -Encoding default %s; exit $LastExitCode"
let &shellquote = ""
let &shellxquote = "\""
src/ex_cmds.c | 31 +++++++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 265927c4cde7..7d2efb61c3e4 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -1532,9 +1532,12 @@ make_filter_cmd(
char_u *buf;
long_u len;
+ char_u *shell_name = get_isolated_shell_name();
+ int is_pwsh = (fnamecmp(shell_name, "powershell") == 0
+ || fnamecmp(shell_name, "pwsh") == 0);
+
#if defined(UNIX)
int is_fish_shell;
- char_u *shell_name = get_isolated_shell_name();
if (shell_name == NULL)
return NULL;
@@ -1544,17 +1547,36 @@ make_filter_cmd(
vim_free(shell_name);
if (is_fish_shell)
len = (long_u)STRLEN(cmd) + 13; // "begin; " + "; end" + NUL
- else
+ else {
No comments:
Post a Comment