-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
fix: powershell redirection for filtered bang commands #19438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Problem: `Start-Process` requires the command to be split into the shell command and its arguments. Previously it was done by parsing, which didn't handle cases such as - commands with escaped space in their filepath - quoted commands with space in their filepath Solution: Use - `pwsh -Command` instead of `Start-Process` - `Get-Content` instead of `-RedirectStandardInput` - `Out-File` instead of `-RedirectStandardOutput`
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 (&).
@3N4N thank you for your tenacity here. Do we need a doc update that mentions these points:
? |
@justinmk Other than the requirement of & before stringed executable path, users don't need to know about the others: it should just work any and every way they try. We can document diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt
index cae9c760308a..c2df8c914b25 100644
--- a/runtime/doc/various.txt
+++ b/runtime/doc/various.txt
@@ -259,6 +259,10 @@ g8 Print the hex values of the bytes used in the
or stderr, the streams are closed immediately. |E5677|
Use |jobstart()| instead. >
:call jobstart('foo', {'detach':1})
+
+ For powershell
8000
, chaining a stringed executable path
+ requires using the call operator (&).
+ :!Write-Output "1`n2" | & "C:\Windows\System32\sort.exe" /r
<
*E34*
Any "!" in {cmd} is replaced with the previous |
Let's start with that. We want to write these things down, else they get lost in time. |
Do you mean push a new commit here, or a new PR? |
new PR |
New behaviour since PR #19438
Successfully created backport PR #20469 for |
one slight incompatibility I found with this is that on unix-like I seem to remember a workaround that does work with this pr is just to use |
Revert #16271 and fix #15913.
Problem:
Since #16271,
make_filter_cmd
usesStart-Process
cmdlet to execute the userprovided shell command for
:%!
.Start-Process
requires the command to besplit into the shell command and its arguments. This was implemented in #19268
by parsing (splitting the user-provided command at the first space) which didn't
handle cases such as --
Solution: Use piping.
The total shell command formats (excluding noise of unimportant parameters):
After this PR, the user can use the following formats:
They can even chain different commands
But if they want to call a stringed executable path, they have to provide the
Invoke-Command operator (&). In fact, the first stringed executable path also
needs this & operator, but this PR adds that behind the scene.
What this PR solves
cmd and its args).
#ifdef
blocks.wrong_cmd.exe not found
)What this PR doesn't solve
Edge cases
&
sign (meanscall this.exe
inpowershell) (I don't plan to handle it)
-Encoding utf8
parameter forGet-Content
? (need to know aboutencoding, which I don't)
using anonymous function (
{wrong_cmd.exe}
))Changes other than
make_filter_cmd()
function