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

cannot cmd in current file whose directory starts with r #40

Open
prabirshrestha opened this issue Jan 13, 2017 · 14 comments
Open

cannot cmd in current file whose directory starts with r #40

prabirshrestha opened this issue Jan 13, 2017 · 14 comments
Labels

Comments

@prabirshrestha
Copy link
Contributor

If I have a file called d:\r\hello.txt and use got with let g:gtfo#terminals = { 'win' : 'cmd' } setting. The cmd opens and closes.

I'm suspecting it has do to something with \r being a special character.

This seems to open correctly.

!start cmd /k "cd /d "d:/r/hello.txt""

/k in cmd says to remain in the terminal so it does not exit after the script is complete.
/d in cd says to change current drive. This would avoid parsing drive letter.

@prabirshrestha prabirshrestha changed the title cannot cmd in current whose directory starts with r cannot cmd in current file whose directory starts with r Jan 13, 2017
@justinmk
Copy link
Owner

gtfo.vim doesn't know the parameters for the numerous terminals in existence; they need to be provided explicitly. Try this instead:

let g:gtfo#terminals = { 'win' : 'cmd /k' }

@prabirshrestha
Copy link
Contributor Author

That seems to solve it. Would be good if it would be added to readme and doc.

@prabirshrestha
Copy link
Contributor Author

prabirshrestha commented Jan 28, 2017

Worked in vim 8 on windows. But that doesn't seem to work on neovim on windows.

Here is what I get.

image

@justinmk
Copy link
Owner

Yep, there are some problems with shell escaping with Nvim on Windows. Please wait until 0.2. is released before using Nvim on Windows :)

@prabirshrestha
Copy link
Contributor Author

I saw that shell escaping PRs have been merged but when I got the latest master from neovim (neovim/neovim@58d2ce9) I still see the same issue. I don't see any issues/PRs tagged with platform:windows. Are there still issues with shell escapes?

I do have set shellslash setting enabled.

@justinmk
Copy link
Owner

justinmk commented Apr 15, 2017

set shellslash with which 'shell' ?

I see that set shellslash works in gvim even if the shell is cmd.exe, but that's going to confuse some plugins. That's something that probably should be "fixed" in nvim, but not a high priority. It's counter to the intended purpose of 'shellslash'...

@justinmk
Copy link
Owner

Would be good if it would be added to readme and doc.

https://github.com/justinmk/vim-gtfo#settings does mention that, but I added a note to https://github.com/justinmk/vim-gtfo#platform-support also.

@prabirshrestha
Copy link
Contributor Author

@justinmk I use set shellslash with cmd to convert \ to / so c:\windows\system32 looks like c:/windows/system32. There are lot of plugin that handles this correctly. Even windows by default supports forward slashes.

image

@justinmk
Copy link
Owner

justinmk commented Apr 17, 2017

@prabirshrestha I thought you indicated that it's only a problem in neovim. Is it a gtfo.vim problem, present in vim and neovim? When I checked it did not seem to be a problem with gtfo.vim + gvim.

There are lot of plugin that handles this correctly.

Almost certainly by accident, e.g. they just happen to not send a path constructed by fnamemodify() to cmd.exe.

Even windows by default supports forward slashes.

Mostly, yes. Try it with del and other commands. Hence why Nvim has to continue the silly dance.

@prabirshrestha
Copy link
Contributor Author

In gvim/vim it works correctly on windows with set shellslash. The problem is only with neovim so I would consider it a bug. Let me know if you would like me to file a bug on neovim to track this.

del a/b.txt doesn't work because some of windows commands uses / as separator.

@justinmk
Copy link
Owner

@prabirshrestha If you can come up with a minimal test case a bug report at neovim repo would be most welcome.

@prabirshrestha
Copy link
Contributor Author

@justinmk Here is the minimal vimrc.

" clone in ~/.vimplugins/vim-gtfo
" git clone https://github.com/justinmk/vim-gtfo .vimplugins/vim-gtfo
set nocompatible
syntax on
filetype plugin indent on

if has('win32') || has('win64')
    set shellslash
endif

set runtimepath+=~/.vimplugins/vim-gtfo

if has('win32') || has('win64')
  let g:gtfo#terminals = { 'win' : 'cmd /k' }
endif

Vim8:

gvim -- -u minimal-vimrc.vim
:e ~/.vimrc
gof
got

gof and got works in Vim8. Now try the same in neovim-qt on windows and it fails nvim-qt -- -u minimal-vimrc.vim. It errors with - The syntax of the command is incorrect. and doesn't open terminal nor the windows explorer. If I remove set shellslash it works in neovim.

@prabirshrestha
Copy link
Contributor Author

@justinmk Still doesn't seem to work with latest neovim 2.2/2.3

@justinmk justinmk reopened this Dec 18, 2017
@justinmk justinmk added bug and removed question labels Dec 18, 2017
@prabirshrestha
Copy link
Contributor Author

@justinmk I think I finally figured out the problem.

This code doesn't work. set shell=$COMSPEC

func! s:force_cmdexe() abort
  if &shell !~? "cmd" || &shellslash
    let s:shell=&shell | let s:shslash=&shellslash | let s:shcmdflag=&shellcmdflag
    set shell=$COMSPEC noshellslash shellcmdflag=/c
  endif
endf

Changing it to the following code seems to work. exec 'set shell='.$COMSPEC.

func! s:force_cmdexe() abort
  if &shell !~? "cmd" || &shellslash
    let s:shell=&shell | let s:shslash=&shellslash | let s:shcmdflag=&shellcmdflag
    exec 'set shell='.$COMSPEC
    set noshellslash shellcmdflag=/c
  endif
endf

Would be possible to update the plugin to use this code in the meantime while we have a proper fix for neovim?

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