Skip to content
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

Subshell command escaping issue when shell is set to powershell. #1298

Closed
trv6 opened this issue Jan 17, 2018 · 2 comments
Closed

Subshell command escaping issue when shell is set to powershell. #1298

trv6 opened this issue Jan 17, 2018 · 2 comments
Labels
Milestone

Comments

@trv6
Copy link

trv6 commented Jan 17, 2018

Information

VIM version
NVIM v0.2.2
Build type: RelWithDebInfo

Operating System: WHAT OS WERE YOU USING?
Windows 7

:ALEInfo

https://gist.github.com/trv6/06cbf33f1655c673bca441756911d857

What went wrong

If shell is set to PowerShell, the subshell command (here) will be parsed by PowerShell, which will throw an error when it tries to parse the redirection operator.

Reproducing the bug

  1. This error should occur regardless of the file type/linter used, but you can download a standalone executable of luacheck here.

  2. In init.vim:

set shell=powershell
let g:ale_lua_luacheck_executable = 'C:/path/to/luacheck.exe' "if you use luacheck for reproducing the bug

You can use the recommended powershell settings here, but I've found they interfere with some powershell commands. The error will still occur in any case.

  1. Edit an appropriate file. I used a Lua file containing only x==1, which should throw a syntax error.
  2. Check ALEInfo.

It was suggested that this is an escaping issue due to ALE's use of subshells here (ignore the bit about the parsing operator and ale_command_wrapper).

The modified block of ale/job.vim:

    if has('win32')
        return 'cmd /s/c "' . l:command . '"'
    endif

does work with both cmd and powershell, though the user who posted the solution recommended that ALE should use batch files instead of subshells.

@w0rp
Copy link
Member

w0rp commented Jan 17, 2018

The commands need to be run in a subshell, especially if you're using PowerShell, which has different syntax. ALE wants to be use CMD syntax for all of the commands it runs. Using a subshell also fixes PATHEXT issues.

It looks like the lines you have written above will work.

@w0rp w0rp added the bug label Jan 17, 2018
@w0rp w0rp closed this as completed in 045c92e Jan 17, 2018
@w0rp w0rp added this to the Version 1.8 milestone Jan 17, 2018
@w0rp
Copy link
Member

w0rp commented Jan 17, 2018

This should be fixed now. Give it a try. Let me know if you have any further issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants