win: defaults: 'shellcmdflag', 'shellxquote' #7343

closes #7698

Wrapping a command in double-quotes allows cmd.exe to safely dequote the
entire command as if the user entered the entire command in an
interactive prompt. This reduces the need to escape nested and uneven
double quotes.

The `/s` flag of cmd.exe makes the behaviour more reliable:

    :set shellcmdflag=/s\ /c

Before this patch, cmd.exe cannot use cygwin echo.exe (as opposed to
cmd.exe `echo` builtin) even if it is wrapped in double quotes.

Example:
:: internal echo
> cmd /s /c " echo foo\:bar" "
foo\:bar"

:: cygwin echo.exe
> cmd /s /c " "echo" foo\:bar" "
foo:bar
This commit is contained in:
Jan Edmund Lazo
2017-09-30 21:31:31 -04:00
committed by Justin M. Keyes
parent be67d926c5
commit 131aad953c
5 changed files with 45 additions and 15 deletions

View File

@@ -2048,7 +2048,7 @@ return {
varname='p_shcf',
defaults={
condition='WIN32',
if_true={vi="/c"},
if_true={vi="/s /c"},
if_false={vi="-c"}
}
},
@@ -2104,7 +2104,11 @@ return {
secure=true,
vi_def=true,
varname='p_sxq',
defaults={if_true={vi=""}}
defaults={
condition='WIN32',
if_true={vi="\""},
if_false={vi=""},
}
},
{
full_name='shellxescape', abbreviation='sxe',