2

I'm attempting to use powershell from gvim, and when I do...I set:

:set shellcmdflag=-NoProfile\ -NoLogo\ -ExecutionPolicy\ RemoteSigned\ -windowStyle\ Normal\ -Command
:set shell='C:\\windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe'
:set shellxquote=

But when I do it runs it like this:

Then I'll run a command like !ls and get this output:

'C:\windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe' -NoProfile -NoLogo -ExecutionPolicy RemoteSigned -windowStyle Normal -Command "ls"
The filename, directory name, or volume label syntax is incorrect.
shell returned 1
Hit any key to close this window...

(note the quotes around the powershell path)

What variable causes those quotes to be there? It is keeping me from running my command.

  • I think you missed some output after your sentence But when I do it runs it like this: – statox Jun 11 at 16:51
  • @statox no that isn’t it I copied and pasted just the bit between the quotes. – leeand00 Jun 11 at 16:55
  • Is that a correct path to the powershell.exe?... If ya try the command (with quotes) within a terminal (without Vim) do ya get different results?... As for why there may be quotes in the output, it's because they'er :set up that way; hint look to shellcmdflag for something :set without quotes. – S0AndS0 Jun 11 at 17:34
2

Why does vim call powershell surrounded by two single quotes?

For it's own protection, maybe, but more than likely someone was thinking about protection of users too; single quotes should mean "don't expand this string" where as double quotes kinda mean "treat the output of this string as an argument"

What variable causes those quotes to be there?

The shell variable that has been :set

:set shell='C:\\windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe'

... without quotes might look like...

:set shell=C:\\windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe

It is keeping me from running my command.

I'd suggest double-checking that file path, including double-checking capitalization, because it might not be the quote's fault that errors be popping.

For example windows may be Windows, though if I've read the docs correctly one might be able to mitigate some of this by using the built in variable %SystemRoot%...

:set shell='%SystemRoot%\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe'
  • 2
    Without quotes did the trick. I guess if the path has spaces you just have to escape them that way. – leeand00 Jun 11 at 18:22
  • Excellent, and glad it helped... though that MS doesn't take kindly to quotes does tempt one to suggest trying out Linux on a USB, because there's likely going to be other issues that'll arise, especially if ya one day want to use plug-ins that didn't code for non-Unix like devices. May seem a little much just for Vim, but as it looks like ya want tighter integration with the host, Linux'll be one of the smoother routes that doesn't cost. However, if the concern is Windows then good luck with that hairline ;-) – S0AndS0 Jun 11 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.