To: vim_dev@googlegroups.com Subject: Patch 8.0.1051 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1051 Problem: Cannot run terminal with spaces in argument. Solution: Accept backslash to escape space and other characters. (closes #1999) Files: src/os_unix.c, src/testdir/test_terminal.vim *** ../vim-8.0.1050/src/os_unix.c 2017-09-01 20:23:58.752539609 +0200 --- src/os_unix.c 2017-09-03 19:24:14.043718153 +0200 *************** *** 4094,4101 **** ++*argc; while (*p != NUL && (inquote || (*p != ' ' && *p != TAB))) { ! if (*p == '"') inquote = !inquote; ++p; } if (*p == NUL) --- 4094,4110 ---- ++*argc; while (*p != NUL && (inquote || (*p != ' ' && *p != TAB))) { ! if (p[0] == '"') 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; } if (*p == NUL) *** ../vim-8.0.1050/src/testdir/test_terminal.vim 2017-09-03 18:07:55.061188862 +0200 --- src/testdir/test_terminal.vim 2017-09-03 19:51:21.389202100 +0200 *************** *** 293,298 **** --- 293,300 ---- let size = term_getsize('') bwipe! call assert_equal([7, 27], size) + + call delete('Xtext') endfunc func Test_terminal_curwin() *************** *** 325,331 **** split dummy bwipe! ! endfunc func Test_finish_open_close() --- 327,333 ---- split dummy bwipe! ! call delete('Xtext') endfunc func Test_finish_open_close() *************** *** 555,557 **** --- 557,575 ---- call assert_equal('look here', term_getline(buf, 1)) bwipe! 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 *** ../vim-8.0.1050/src/version.c 2017-09-03 19:15:51.698932854 +0200 --- src/version.c 2017-09-03 19:25:49.315107751 +0200 *************** *** 771,772 **** --- 771,774 ---- { /* Add new patch number below this line */ + /**/ + 1051, /**/ -- hundred-and-one symptoms of being an internet addict: 71. You wonder how people walk /// Bram Moolenaar -- Bram@Moolenaar.net -- 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 ///