[vim/vim] system([]) syntax is erroring with PowerShell (Issue #9095)

130 views
Skip to first unread message

Zovin Khanmohammed

unread,
Nov 5, 2021, 4:25:39 PM11/5/21
to vim/vim, Subscribed

Steps to reproduce

  1. running vim with command vim --clean --cmd 'set shell=pwsh' or vim --clean --cmd 'set shell=powershell'
  2. run :echo system(['git','version'])
  3. Get Errors

If using shell=powershell

2>&1 : The term '2>&1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

If using shell=pwsh

>: The term '>' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.


E484: Can't open file C:\Users\ZOVIN~1.KHA\AppData\Local\Temp\VNJ8B28.tmp

Expected behaviour

Should have an output like :echo system('git --version')
for example
image

Operating system

Windows 10 21H1/20H2

Version of Vim

8.2.3579

Logs and stack traces

>: The term '>' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.


E484: Can't open file C:\Users\ZOVIN~1.KHA\AppData\Local\Temp\VJB6942.tmp


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

lacygoill

unread,
Nov 5, 2021, 5:53:27 PM11/5/21
to vim/vim, Subscribed

run :echo system(['git','version'])

Is system() supposed to accept a list on Windows? It doesn't on Linux:

:echo system([])
E730: Using a List as a String

What's the output if you temporarily increase the verbosity level to 4:

:4verbose echo system(['git','version'])

Zovin Khanmohammed

unread,
Nov 5, 2021, 5:56:12 PM11/5/21
to vim/vim, Subscribed

So interestingly there the error does come up, however it still tries to execute:

The output with full verbosity (pwsh)

E730: Using a List as a String
Calling shell to execute: " >C:\Users\ZOVIN~1.KHA\AppData\Local\Temp\VZ77BB2.tmp 2>&1"
>: The term '>' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.


E484: Can't open file C:\Users\ZOVIN~1.KHA\AppData\Local\Temp\VZ77BB2.tmp

Christian Brabandt

unread,
Nov 5, 2021, 5:57:35 PM11/5/21
to vim/vim, Subscribed
run :echo system(['git','version'])

Is system() supposed to accept a list on Windows? It doesn't on Linux:

Looks like this is also Neovim: https://neovim.io/doc/user/eval.html#system()

Please test with a Vim version, before report things there.

Christian Brabandt

unread,
Nov 5, 2021, 5:57:39 PM11/5/21
to vim/vim, Subscribed

Closed #9095.

lacygoill

unread,
Nov 5, 2021, 5:58:24 PM11/5/21
to vim/vim, Subscribed

Is system() supposed to accept a list on Windows? It doesn't on Linux:

According to :help system(), the first argument can only be a string:

Get the output of the shell command {expr} as a string.

Are you conflating system() with job_start()? The latter does accept a list as first argument.

Zovin Khanmohammed

unread,
Nov 5, 2021, 6:04:55 PM11/5/21
to vim/vim, Subscribed

ah dang, I got confused by the second paragraph in :help system() about if input is a list.

Between junegunn/vim-plug/plug.vim#L461-466 and that paragraph, I thought system([]) was valid vim syntax. Explains why vim-plug is broke for me....

Reply all
Reply to author
Forward
0 new messages