On Wednesday, September 11, 2013 10:13:17 AM UTC-5, Jan Stocker wrote:
> 
> 
> 
> So how would you run a valid cmd.exe line
> 
> 
> 
> "c:\program files (x86)\xyz\xyz.exe" "arg1 with spaces" "arg 2 with spaces"
> 
> 

This is exactly the situation that the changes were designed for! For me the 
defaults work. I just now launched vim with "gvim -N -u NONE -i NONE" and ran 
this command, getting the expected diff output in a command window:

:!"C:\Program Files (x86)\vim\vim74\diff.exe" 
"C:\Users\btfritz\AppData\Local\Temp\file 1.txt" 
"C:\Users\btfritz\AppData\Local\Temp\file 2.txt"

> 
> from a script rather than 
> 
> 
> 
> exe 'r!cmd.exe /c ""c:\program files (x86)\xyz\xyz.exe" "arg1 with spaces" 
> "arg 2 with spaces""'
> 
> 

This is an old-style workaround for the bad defaults. Adding an extra " at the 
beginning and end of the string and allowing cmd.exe to strip them off is how 
this works.

The problem is now you're escaping the special characters only once, but you're 
running cmd.exe twice. So you need to escape them manually to prevent the 
implicitly called cmd.exe from seeing unescaped special characters outside of 
matching quotes. Or, just call the program directly instead of wrapping it with 
cmd.exe.

I.e. you can use my command above, or this variant:

:!cmd /c ""C:\Program Files ^(x86^)\vim\vim74\diff.exe" 
"C:\Users\btfritz\AppData\Local\Temp\file 1.txt" 
"C:\Users\btfritz\AppData\Local\Temp\file 2.txt""

> 
> which does not work with default settings under 7.4 (I patched it today using 
> short file names, but that is no solution)?
> 
> 

Patch it instead to use the full command.

> 
> And what to do to run this for 7.3 (some version before the patch) AND 7.4?
> 

In this specific case, you can check the version and patchlevel using 
(v:version<7.3 || v:version==7.3 && !has('patch450')) and set 'shellxquote' to 
a single " character if true. This uses Vim to automatically surround the 
entire thing in an extra pair of quotes like the existing code does manually. 
This would have been the correct fix in the first place instead of this 
workaround.

Naturally you'll need to save and restore shellxquote around this. And only do 
this on Windows.

Something like (untested):

if has('win32') && (v:version<7.3 || v:version==7.3 && !has('patch450')) && 
&shell=~cmd
  let s:shxq_sav = &shellxquote
  set shellxquote="
endif
!"c:\program files (x86)\xyz\xyz.exe" "arg1 with spaces" "arg 2 with spaces"
if exists('s:shxq_sav')
  let &shellxquote = s:shxq_sav
  unlet s:shxq_sav
endif

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Raspunde prin e-mail lui