forked from aniani/vim
patch 8.0.1051: cannot run terminal with spaces in argument
Problem: Cannot run terminal with spaces in argument. Solution: Accept backslash to escape space and other characters. (closes #1999)
This commit is contained in:
@@ -4094,8 +4094,17 @@ mch_parse_cmd(char_u *cmd, int use_shcf, char ***argv, int *argc)
|
|||||||
++*argc;
|
++*argc;
|
||||||
while (*p != NUL && (inquote || (*p != ' ' && *p != TAB)))
|
while (*p != NUL && (inquote || (*p != ' ' && *p != TAB)))
|
||||||
{
|
{
|
||||||
if (*p == '"')
|
if (p[0] == '"')
|
||||||
inquote = !inquote;
|
inquote = !inquote;
|
||||||
|
else if (p[0] == '\\' && p[1] != NUL)
|
||||||
|
{
|
||||||
|
/* First pass: skip over "\ " and "\"".
|
||||||
|
* Second pass: Remove the backslash. */
|
||||||
|
if (i == 1)
|
||||||
|
mch_memmove(p, p + 1, STRLEN(p));
|
||||||
|
else
|
||||||
|
++p;
|
||||||
|
}
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
if (*p == NUL)
|
if (*p == NUL)
|
||||||
|
@@ -293,6 +293,8 @@ func Test_terminal_size()
|
|||||||
let size = term_getsize('')
|
let size = term_getsize('')
|
||||||
bwipe!
|
bwipe!
|
||||||
call assert_equal([7, 27], size)
|
call assert_equal([7, 27], size)
|
||||||
|
|
||||||
|
call delete('Xtext')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_terminal_curwin()
|
func Test_terminal_curwin()
|
||||||
@@ -325,7 +327,7 @@ func Test_terminal_curwin()
|
|||||||
|
|
||||||
split dummy
|
split dummy
|
||||||
bwipe!
|
bwipe!
|
||||||
|
call delete('Xtext')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_finish_open_close()
|
func Test_finish_open_close()
|
||||||
@@ -555,3 +557,19 @@ func Test_terminal_no_cmd()
|
|||||||
call assert_equal('look here', term_getline(buf, 1))
|
call assert_equal('look here', term_getline(buf, 1))
|
||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_terminal_special_chars()
|
||||||
|
" this file name only works on Unix
|
||||||
|
if !has('unix')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
call mkdir('Xdir with spaces')
|
||||||
|
call writefile(['x'], 'Xdir with spaces/quoted"file')
|
||||||
|
term ls Xdir\ with\ spaces/quoted\"file
|
||||||
|
call WaitFor('term_getline("", 1) =~ "quoted"')
|
||||||
|
call assert_match('quoted"file', term_getline('', 1))
|
||||||
|
call term_wait('')
|
||||||
|
|
||||||
|
call delete('Xdir with spaces', 'rf')
|
||||||
|
bwipe
|
||||||
|
endfunc
|
||||||
|
@@ -769,6 +769,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1051,
|
||||||
/**/
|
/**/
|
||||||
1050,
|
1050,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user