Skip to content

Commit

Permalink
vim: fix shell options for cmd.exe
Browse files Browse the repository at this point in the history
Reference:
junegunn/fzf#1018 (comment)

The command passed to cmd.exe is run as if the user typed it all
in an interactive prompt. This is convenient for testing and reduces the
burden to shellescape each token. This is enough for basic commands.
For non-trivial commands, use a batchfile.
  • Loading branch information
janlazo committed Sep 30, 2017
1 parent 87a0f93 commit d0663c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 3 additions & 8 deletions autoload/dotvim8.vim
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,10 @@ function! dotvim8#set_shell(shell)

if shell ==# 'cmd.exe'
let &shell = a:shell
set shellcmdflag=/c shellquote=
let &shellcmdflag = '/s /c'
let &shellxquote= '"'
set shellxescape= shellquote=
let &shellredir = '>%s 2>&1'

if has('nvim')
set shellxquote= shellxescape=
else
set shellxquote=(
let &shellxescape = '"&|<>()@^'
endif
elseif shell ==# 'powershell.exe'
let &shell = a:shell
let &shellcmdflag = '-NoProfile -NoLogo -Command'
Expand Down
6 changes: 6 additions & 0 deletions shared.vim
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@ if has('win32')
return expand(s:base_dir . '/spell')
endfunction
endif

" Fix shell options for cmd.exe such that the command is run
" as if it was typed in an interactive prompt
if &shell =~# 'cmd.exe'
set shellcmdflag=/s\ /c shellxquote=\" shellxescape=
endif
endif
" }}}huge

Expand Down

0 comments on commit d0663c7

Please sign in to comment.