-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello Vim developers,

I use the easytags.vim plugin, which invokes another Vim instance, its
arguments properly escaped via shellescape(). On Windows, this doubles "
into "". Starting with
,----[ Patch 7.4.432 ]----
| MS-Windows: setting 'encoding' does not convert arguments
`----
this causes startup errors in the launched Vim instance, breaking the
plugin, and causing stray vim.exe processes to accumulate. (This is with
a HUGE Vim on Windows/x64, compiled with Windows SDK 7.1 / cl.exe
version 16.00.40219.01 for x64, if it matters.)

,----[ how to reproduce ]----
| vim.exe -N -u NONE -c "let test = 'a ""quoted"" string'"
| Error detected while processing command line:
| E115: Missing quote: 'a "quoted
| E15: Invalid expression: 'a "quoted
`----

I know that shell quoting on Windows is a hairy mess, and after reading
some relevant articles ([1] and [2] are very detailed), I feel like I
understand _less_ how it is supposed to work :-(

Fact is, that patch changed the command-line parsing, but I don't know
how it could possibly affect the quoting behavior. What I did find out
is that _tripling_ (instead of doubling) fixes the problem for me. Some
experiments with findstr.exe also showed equal or better results with
tripling [3].

So attached is a workaround that changes shellescape() to triple instead
of double " on Windows. With that, easytags is working again (also when
it invokes an older Vim), and in a week of use, I didn't notice any
problems.
Of course, I'd prefer to have Vim's command-line parsing corrected so
that doubled "" do work again. If some Windows guru (or Matsumoto-san as
the author of the original patch) achieves this, that'd be great!

- -- regards, ingo

[1] http://www.daviddeley.com/autohotkey/parameters/parameters.htm
[2]
http://stackoverflow.com/questions/4094699/how-does-the-windows-command-interpreter-cmd-exe-parse-scripts
[3] > echo.a"foo"in here | findstr /L "a""foo"
    a"foo"in here

    > echo.a"foo"in here | findstr /L "a""foo"""
    a"foo"in here

    > echo.a"foo"in here | findstr /L "a""foo""in"

    > echo.a"foo"in here | findstr /L "a"""foo"""in"
    a"foo"in here

    > echo.a"foo"in here|findstr /X /C:"a"foo"in here"

    > echo.a"foo"in here|findstr /X /C:"a""foo""in here"
    FINDSTR: Cannot open here

    > echo.a"foo"in here|findstr /X /C:"a"""foo"""in here"
    a"foo"in here

    > echo.a"foo"in here|findstr /X /C:"a""""foo""""in here"
    a"foo"in here

    > echo.a"foo"in here|findstr /X /C:"a\"foo\"in here"
    a"foo"in here
- -- 
  -- Ingo Karkat --  /^-- /^-- /^-- /^-- /^-- http://ingo-karkat.de/ --
  --   http://vim.sourceforge.net/account/profile.php?user_id=9713   --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)

iQEcBAEBAgAGBQJUuSvbAAoJEA7ziXlAzQ/v2iUIAI71K54IE9zHj/dswjTGzcIK
+Fwi5dtLsUzQIhDvZ9ksdQOVC+1rScRmNm3l9XyKEx0jvfAifaQdhtgGhWLajZ21
ZF86oBmBdm4WqwL+gcEq+8cJMRpD67WCns4FWiTyxN6x5qhuvNA2wIoOxt5/jfI4
YyUw2hdwgGUUyl/MeRCYLqeh8+IxjyAltRvAlCC3pB/lonAPzBtEBbQpoVRf9t97
REVN+wZIaAf0r5WCSArd1EfBkNbKaK17oR2fPtxH9YB6oagyyAOzQzaOXLcLou0i
I/OObKW+biMToW/oqJAdmnr3fwa/nprOWS2luZCn+A2VQikV5v8RBfPsXhskBNw=
=7rlR
-----END PGP SIGNATURE-----

-- 
-- 
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/d/optout.
diff --git a/src/misc2.c b/src/misc2.c
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -1392,7 +1392,7 @@ vim_strsave_shellescape(string, do_speci
 	if (!p_ssl)
 	{
 	    if (*p == '"')
-		++length;		/* " -> "" */
+		length = length + 2;		/* " -> """ */
 	}
 	else
 # endif
@@ -1435,6 +1435,7 @@ vim_strsave_shellescape(string, do_speci
 		{
 		    *d++ = '"';
 		    *d++ = '"';
+		    *d++ = '"';
 		    ++p;
 		    continue;
 		}

Attachment: shellescape-Windows.patch.sig
Description: Binary data

Raspunde prin e-mail lui