[vim/vim] :! {cmd} quoting issues on windows 10 when using bash as shell (#4950)

44 views
Skip to first unread message

CrispyDrone

unread,
Sep 17, 2019, 6:10:01 PM9/17/19
to vim/vim, Subscribed

Describe the bug
I've exhausted all options and followed the documentation but am unable to get :! {cmd} to work with the following shell configuration:

set shell=\"$PROGRAMW6432\Git\bin\bash.exe\"

I've also the tried the following and more:

set shell=$PROGRAMW6432\Git\bin\bash.exe
set shell=$PROGRAMW6432/Git/bin/bash.exe
set shell=\"\"$PROGRAMW6432/Git/bin/bash.exe\"\"
set shell=\'\"$PROGRAMW6432/Git/bin/bash.exe\"\'
set shell=\"\'$PROGRAMW6432/Git/bin/bash.exe\'\"
set shell=\'$PROGRAMW6432/Git/bin/bash.exe\'
set shell=\"C:\Program Files\Git\bin\bash.exe\"
set shell=\"C:\Program\ Files\Git\bin\bash.exe\"
set shell=\"C:\Program\\ Files\Git\bin\bash.exe\"
set shell=\"C:\Program\\\ Files\Git\bin\bash.exe\"
set shell=C:\Program\\\ Files\Git\bin\bash.exe
...

To Reproduce

  1. Run vim -u .vimrc where .vimrc contains the single set shell line of configuration.
  2. Execute for example :!ls
  3. Receive the error message as shown in the screenshot

Expected behavior
The {cmd} is executed in the configured shell.

Screenshots
'Program' is not recognized as an internal or external command: quoting issues...

Environment:

VIM - Vi IMproved 8.1 (2018 May 18, compiled May 18 2018 18:36:07)
MS-Windows 32-bit GUI version with OLE support
Included patches: 1
Compiled by mool@tororo
Huge version with GUI.  Features included (+) or not (-):
+acl                +channel            +cryptv             -ebcdic             +folding            +lambda             +mksession          +ole                +python3/dyn        +statusline         -tgetent            +visual             -xfontset
+arabic             +cindent            +cscope             +emacs_tags         -footer             +langmap            +modify_fname       +packages           +quickfix           -sun_workshop       -termresponse       +visualextra        -xim
+autocmd            +clientserver       +cursorbind         +eval               +gettext/dyn        +libcall            +mouse              +path_extra         +reltime            +syntax             +textobjects        +viminfo            +xpm_w32
+autoservername     +clipboard          +cursorshape        +ex_extra           -hangul_input       +linebreak          +mouseshape         +perl/dyn           +rightleft          +tag_binary         +timers             +vreplace           -xterm_save
+balloon_eval       +cmdline_compl      +dialog_con_gui     +extra_search       +iconv/dyn          +lispindent         +multi_byte_ime/dyn +persistent_undo    +ruby/dyn           +tag_old_static     +title              -vtp                
-balloon_eval_term  +cmdline_hist       +diff               +farsi              +insert_expand      +listcmds           +multi_lang         -postscript         +scrollbind         -tag_any_white      +toolbar            +wildignore         
+browse             +cmdline_info       +digraphs           +file_in_path       +job                +localmap           +mzscheme/dyn       +printer            +signs              +tcl/dyn            +user_commands      +wildmenu           
++builtin_terms     +comments           +directx            +find_in_path       +jumplist           +lua/dyn            +netbeans_intg      +profile            +smartindent        -termguicolors      +vertsplit          +windows            
+byte_offset        +conceal            -dnd                +float              +keymap             +menu               +num64              +python/dyn         +startuptime        +terminal           +virtualedit        +writebackup        
   system vimrc file: "$VIM\vimrc"
     user vimrc file: "$HOME\_vimrc"
 2nd user vimrc file: "$HOME\vimfiles\vimrc"
 3rd user vimrc file: "$VIM\_vimrc"
      user exrc file: "$HOME\_exrc"
  2nd user exrc file: "$VIM\_exrc"
  system gvimrc file: "$VIM\gvimrc"
    user gvimrc file: "$HOME\_gvimrc"
2nd user gvimrc file: "$HOME\vimfiles\gvimrc"
3rd user gvimrc file: "$VIM\_gvimrc"
       defaults file: "$VIMRUNTIME\defaults.vim"
    system menu file: "$VIMRUNTIME\menu.vim"
Compilation: cl -c /W3 /nologo  -I. -Iproto -DHAVE_PATHDEF -DWIN32  -DFEAT_CSCOPE -DFEAT_TERMINAL -DFEAT_NETBEANS_INTG -DFEAT_JOB_CHANNEL   -DFEAT_XPM_W32   -DWINVER=0x0501 -D_WIN32_WINNT=0x0501 /MP -DHAVE_STDINT_H /Ox /GL -DNDEBUG /arch:IA32 /Zl /MT -DFEAT_OLE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DFEAT_GUI_W32 -DFEAT_DIRECTX -DDYNAMIC_DIRECTX -DFEAT_DIRECTX_COLOR_EMOJI -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_TCL -DDYNAMIC_TCL -DDYNAMIC_TCL_DLL=\"tcl86t.dll\" -DDYNAMIC_TCL_VER=\"8.6\" -DFEAT_LUA -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL=\"lua53.dll\" -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python27.dll\" -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"python36.dll\" -DFEAT_MZSCHEME -I "E:\Racket\include" -DMZ_PRECISE_GC -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\"libracket3m_a36fs8.dll\" -DDYNAMIC_MZGC_DLL=\"libracket3m_a36fs8.dll\" -DFEAT_PERL -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\"perl524.dll\" -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_VER=24 -DDYNAMIC_RUBY_DLL=\"msvcrt-ruby240.dll\" -DFEAT_HUGE /Fd.\ObjGXOULYHTRZi386/ /Zi
Linking: link  /nologo /subsystem:windows,5.01 /opt:ref /LTCG:STATUS oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib  comdlg32.lib ole32.lib uuid.lib /machine:i386 gdi32.lib version.lib   winspool.lib comctl32.lib advapi32.lib shell32.lib  /machine:i386  libcmt.lib oleaut32.lib user32.lib  /nodefaultlib:lua53.lib  /STACK:8388608  /nodefaultlib:python27.lib /nodefaultlib:python36.lib   "E:\ActiveTcl\lib\tclstub86.lib" WSock32.lib xpm\x86\lib-vc14\libXpm.lib /PDB:gvim.pdb -debug
  • OS: Windows 10 Home Version 1903 OS build 18362.295
  • Terminal: GUI
  • Git: version 2.22.0.windows.1
  • Mintty: mintty 3.0.1 (x86_64-pc-msys)
    Type: xterm


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

Michael Soyka

unread,
Sep 17, 2019, 8:11:43 PM9/17/19
to vim_dev
In my version of git-for-windows, bash defines that environment variable as ProgramW6432. 

K.Takata

unread,
Sep 17, 2019, 8:16:35 PM9/17/19
to vim/vim, Subscribed

Related: #4920

Christian Brabandt

unread,
Sep 18, 2019, 2:47:40 AM9/18/19
to vim/vim, Subscribed

Have you tried using :let &shell syntax. This should make quoting easier. Try using an absolute path.

CrispyDrone

unread,
Sep 18, 2019, 1:23:16 PM9/18/19
to vim/vim, Subscribed

Hello,

I've tried :let &shell with every possibility I can come up with with no luck so far. Both with the environment variable and with an absolute path.

Andy Wokula

unread,
Sep 18, 2019, 2:53:32 PM9/18/19
to vim...@googlegroups.com
Am 18.09.2019 um 00:09 schrieb CrispyDrone (Vim Github Repository):
> *Describe the bug*
> I've exhausted all options and followed the documentation but am unable to get |:! {cmd}| to work with the following shell configuration:
>
> |set shell=\"$PROGRAMW6432\Git\bin\bash.exe\"
> |
>
> I've also the tried the following and more:
>
> |set shell=$PROGRAMW6432\Git\bin\bash.exe
> set shell=$PROGRAMW6432/Git/bin/bash.exe
> set shell=\"\"$PROGRAMW6432/Git/bin/bash.exe\"\"
> set shell=\'\"$PROGRAMW6432/Git/bin/bash.exe\"\'
> set shell=\"\'$PROGRAMW6432/Git/bin/bash.exe\'\"
> set shell=\'$PROGRAMW6432/Git/bin/bash.exe\'
> set shell=\"C:\Program Files\Git\bin\bash.exe\"
> set shell=\"C:\Program\ Files\Git\bin\bash.exe\"
> set shell=\"C:\Program\\ Files\Git\bin\bash.exe\"
> set shell=\"C:\Program\\\ Files\Git\bin\bash.exe\"
> set shell=C:\Program\\\ Files\Git\bin\bash.exe
> ..
> |
>
> *To Reproduce*
>
> 1. Run |vim -u .vimrc| where .vimrc contains the single |set shell| line of configuration.
> 2. Execute for example |:!ls|
> 3. Receive the error message as shown in the screenshot
>
> *Expected behavior*
> The |{cmd}| is executed in the configured shell.
>
> *Screenshots*
> 'Program' is not recognized as an internal or external command: quoting issues... <https://user-images.githubusercontent.com/37639058/65081954-1237f880-d9a5-11e9-8c29-2ed96b7f7c2b.png>
>
> *Environment:*

Other things to try:
:let &shell = substitute(expand('$PROGRAMW6432\Git\bin\bash.exe'), ' ', '^ ', 'g')
:let &shell = substitute('C:\Program Files\Git\bin\bash.exe', ' ', '^ ', 'g')
:let &shell = 'C:\Program" "Files\Git\bin\bash.exe'

--
Andy

Houl

unread,
Sep 27, 2019, 10:35:46 AM9/27/19
to vim/vim, Subscribed

Other things to try:

:let &shell = substitute(expand('$PROGRAMW6432\Git\bin\bash.exe'), ' ', '^ ', 'g')
:let &shell = 'C:\Program^ Files\Git\bin\bash.exe'
:let &shell = 'C:\Program" "Files\Git\bin\bash.exe'

First reply went to the mailing list :-/

CrispyDrone

unread,
Sep 29, 2019, 8:31:02 AM9/29/19
to vim/vim, Subscribed

Hello,

Thank you for your suggestions. Unfortunately I tried all of them to no avail. None of them succeeded at creating a terminal inside vim with :term (CreateProcess failed).

Here are the screenshots corresponding to each one of them respectively when trying :!ls:

let &shell = substitute(expand('$PROGRAMW6432\Git\bin\bash.exe'), ' ', '^ ', 'g')

term-04

let &shell = 'C:\Program^ Files\Git\bin\bash.exe'

term-05

let &shell = 'C:\Program" "Files\Git\bin\bash.exe'

term-06

Houl

unread,
Sep 29, 2019, 11:41:18 AM9/29/19
to vim/vim, Subscribed

At least it's one step further: the error is reported from bash.exe.
Now bash sees Files\Git\bin\bash.exe as first argument, that's really weird.

Christian Brabandt

unread,
Oct 2, 2019, 8:14:07 AM10/2/19
to vim/vim, Subscribed

How about this ugly workaround:

let &shell=fnamemodify(expand('$PROGRAMW6432\Git\bin\bash.exe'), ':8')

K.Takata

unread,
Oct 2, 2019, 10:40:17 AM10/2/19
to vim/vim, Subscribed

If you can build Vim by yourself, try #4920.

CrispyDrone

unread,
Oct 2, 2019, 3:32:20 PM10/2/19
to vim/vim, Subscribed

How about this ugly workaround:

let &shell=fnamemodify(expand('$PROGRAMW6432\Git\bin\bash.exe'), ':8')

Thank you for the suggestion. This seems to work. However, vundle's :PluginInstall is still broken, but that might of course be an issue on Vundle's side.

If you can build Vim by yourself, try #4920.

I have never done it before, but I will give it a try as soon as possible and give you an update.

Thanks everyone.

K.Takata

unread,
Oct 5, 2019, 10:22:11 AM10/5/19
to vim/vim, Subscribed

Closed #4950.

K.Takata

unread,
Oct 5, 2019, 10:22:11 AM10/5/19
to vim/vim, Subscribed

This should be fixed with 8.1.2115.

Reply all
Reply to author
Forward
0 new messages