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

Support for Unix Shell Flavors and Command Prompt on Windows Simultaneously (Patch Included) #99

Closed
Alexander-Shukaev opened this issue Nov 27, 2013 · 3 comments

Comments

@Alexander-Shukaev
Copy link

This bug has been bothering me for several weeks by now. Here is the patch:

--- autoload/sy/util.vim.orig   2013-11-27 10:57:13.622643600 +0100
+++ autoload/sy/util.vim    2013-11-27 10:47:50.253420800 +0100
@@ -6,7 +6,12 @@
 function! sy#util#escape(path) abort
   if exists('+shellslash')
     let old_ssl = &shellslash
-    set noshellslash
+
+    if fnamemodify(&shell, ':t') == 'cmd.exe'
+      set noshellslash
+    else
+      set shellslash
+    endif
   endif

   let path = shellescape(a:path)

So, basically, when one starts Vim from Command Prompt (cmd.exe), then &shell points to cmd.exe indeed, and paths for system() call have to be escaped with noshellslash. However, when one starts Vim from Sh, Bash, Ksh, Csh, etc., then &shell points to one of them, and, in this case, paths for system() call have to be escaped with shellslash, otherwise everything breaks because of backward slashes \ in paths.

I've tested this, and I can assure you that it works fine. Please, incorporate this fix upstream. Thank you.

@mhinz mhinz closed this as completed in a7c83f6 Nov 30, 2013
@mhinz
Copy link
Owner

mhinz commented Nov 30, 2013

Thanks!

Out of interest: what terminal emulators/shells do Windows users usually use? cmd.exe, powershell, cygwin, ..?

And I figure cmd.exe is the only one using backslashes?

@Alexander-Shukaev
Copy link
Author

cmd.exe and PowerShell.exe the only ones to use backward slashes. You're probably more interested not in terminal emulators, but in shells. As for shells, yes: cmd.exe, PowerShell.exe, bash.exe, sh.exe, zsh.exe, ksh.exe, csh.exe. Yes, we have ports of all Unix shell flavors available, and they all use forward slashes.

@mhinz
Copy link
Owner

mhinz commented Nov 30, 2013

I see, thanks.

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

No branches or pull requests

2 participants