aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEnan Ajmain <3nan.ajmain@gmail.com>2022-07-20 20:55:28 +0600
committerEnan Ajmain <3nan.ajmain@gmail.com>2022-09-30 21:08:45 +0600
commitf2482b3b533c8ed131a33aaead332c226a9e6aca (patch)
tree83a82fe714b937f0b564a0d765d2796bbcac3326 /src
parentb4d42bb9058308c38e3fe9d59458ce65b3f65eb0 (diff)
downloadrneovim-f2482b3b533c8ed131a33aaead332c226a9e6aca.tar.gz
rneovim-f2482b3b533c8ed131a33aaead332c226a9e6aca.tar.bz2
rneovim-f2482b3b533c8ed131a33aaead332c226a9e6aca.zip
fix: :! pwsh redirection for `command not found`
Problem: If the shell command passed to the filtered bang command isn't found, the error isn't redirected to the temp.out file when shell is set to powershell. Solution: Use anonymous function with Invoke-Command operator (&).
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_cmds.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index a6a4f52323..77feddbbf9 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -1549,7 +1549,7 @@ char *make_filter_cmd(char *cmd, char *itmp, char *otmp)
: 0;
if (itmp != NULL) {
- len += is_pwsh ? strlen(itmp) + sizeof("Get-Content " " | & ") - 1
+ len += is_pwsh ? strlen(itmp) + sizeof("& { Get-Content " " | & " " }") - 1
: strlen(itmp) + sizeof(" { " " < " " } ") - 1;
}
if (otmp != NULL) {
@@ -1560,10 +1560,11 @@ char *make_filter_cmd(char *cmd, char *itmp, char *otmp)
if (is_pwsh) {
if (itmp != NULL) {
- xstrlcpy(buf, "Get-Content ", len - 1); // FIXME: should we add "-Encoding utf8"?
+ xstrlcpy(buf, "& { Get-Content ", len - 1); // FIXME: should we add "-Encoding utf8"?
xstrlcat(buf, (const char *)itmp, len - 1);
xstrlcat(buf, " | & ", len - 1); // FIXME: add `&` ourself or leave to user?
xstrlcat(buf, cmd, len - 1);
+ xstrlcat(buf, " }", len - 1);
} else {
xstrlcpy(buf, cmd, len - 1);
}