Yasuhiro Matsumoto wrote:
> > > On Monday, October 3, 2016 at 7:49:20 AM UTC+9, Ozaki Kiichi wrote:
> > > >
> > > > https://gist.github.com/ichizok/6e0c00daf387b32bebcc2972f0cca137
> > >
> > > Bram, in this patch, you can see workaround to avoid a bug with escaping
> > > double-quote on Windows.
> > >
> > > https://gist.github.com/ichizok/6e0c00daf387b32bebcc2972f0cca137#file-fix-job-channel-patch-L202-L207
> > >
> > > I'm working this in separately. I'll report a description and send patch
> > > in later.
> >
> > Thanks. Escaping is tricky. Please check a few different shells.
> > Checking for Win32 might not be right when 'shell' is not cmd.exe but a
> > Unix-shell-like.
>
> No need to check shell(s) because job_start doesn't use shell to start
> process. And the problem occur only on Windows.
>
> shellexecute() make dup for double-quote like below.
>
> shellescape('"') => """" (This mean " and "" and " )
>
> This is right behavior when using cmd.exe. But not right for starting process
> without cmd.exe. Below is a test program.
>
> foo.c
> ------------
> #include <windows.h>
>
> int
> main(int argc, char* argv[]) {
> MessageBox(0, argv[1], "foo", MB_OK);
> return 0;
> }
> ------------
>
> C:\>foo.exe """"
>
> This should work because it runs on cmd.exe. But it doesn't work when
> starting process without cmd.exe. Please try following.
>
> ------------
> #include <windows.h>
> #include <stdio.h>
>
> int
> main(int argc, char* argv[]) {
> PROCESS_INFORMATION pi;
> STARTUPINFO si;
> ZeroMemory(&si, sizeof(STARTUPINFO));
> CreateProcess(NULL, "foo \"import sys;sys.stdout.write(""1\\n2\\n3"")\"",
> NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi);
> WaitForSingleObject(pi.hProcess, INFINITE);
> }
> ------------
>
> You expect this to display quoted "1\n2\n3" but this display non-quoted
> 1\n2\n3.
>
> http://go-gyazo.appspot.com/949aca13dc74e8c3.png
>
> See this article.
> https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/
>
> We should escape double-quote as \" instead of "" if we run without cmd.exe,
> so we MUST NOT use shellescape for this. Below is an implementation of this
> escaping.
>
> https://gist.github.com/d47e7d3bfe5ade4be86062b565a4bfca
>
> This change will be tested via Test_read_nonl_line.
Thanks for diving into this. But I think this needs more testing, since
it's quite different from what we have before.
I think the "escaping" value needs to be reset after
for (i = 0; i < escaping; i++)
Looks like you get there with a sequence \""
--
The early bird gets the worm. If you want something else for
breakfast, get up later.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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.