@@ -1192,23 +1192,29 @@ install_vimrc(int idx)
11921192 fprintf (fd , " if arg3 =~ ' ' | let arg3 = '\"' . arg3 . '\"' | endif\n" );
11931193
11941194 /* If the path has a space: When using cmd.exe (Win NT/2000/XP) put
1195- * quotes around the whole command and around the diff command.
1195+ * quotes around the diff command and rely on the default value of
1196+ * shellxquote to solve the quoting problem for the whole command.
1197+ *
11961198 * Otherwise put a double quote just before the space and at the
11971199 * end of the command. Putting quotes around the whole thing
11981200 * doesn't work on Win 95/98/ME. This is mostly guessed! */
1199- fprintf (fd , " let eq = ''\n" );
12001201 fprintf (fd , " if $VIMRUNTIME =~ ' '\n" );
12011202 fprintf (fd , " if &sh =~ '\\<cmd'\n" );
1202- fprintf (fd , " let cmd = '\"\"' . $VIMRUNTIME . '\\diff\"'\n" );
1203- fprintf (fd , " let eq = '\"'\n" );
1203+ fprintf (fd , " if empty(&shellxquote)\n" );
1204+ fprintf (fd , " let l:shxq_sav = ''\n" );
1205+ fprintf (fd , " set shellxquote&\n" );
1206+ fprintf (fd , " endif\n" );
1207+ fprintf (fd , " let cmd = '\"' . $VIMRUNTIME . '\\diff\"'\n" );
12041208 fprintf (fd , " else\n" );
12051209 fprintf (fd , " let cmd = substitute($VIMRUNTIME, ' ', '\" ', '') . '\\diff\"'\n" );
12061210 fprintf (fd , " endif\n" );
12071211 fprintf (fd , " else\n" );
12081212 fprintf (fd , " let cmd = $VIMRUNTIME . '\\diff'\n" );
12091213 fprintf (fd , " endif\n" );
1210- fprintf (fd , " silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq\n" );
1211-
1214+ fprintf (fd , " silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3\n" );
1215+ fprintf (fd , " if exists('l:shxq_sav')\n" );
1216+ fprintf (fd , " let &shellxquote=l:shxq_sav\n" );
1217+ fprintf (fd , " endif\n" );
12121218 fprintf (fd , "endfunction\n" );
12131219 fprintf (fd , "\n" );
12141220 }
0 commit comments