Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
:help systemlist() says: > Output is the same as readfile() will output with {binary} argument > set to "b". And :help readfile() says: > When {binary} contains "b" binary mode is used: > - When the last line ends in a NL an extra empty list item is > added. > - No CR characters are removed. systemlist() doesn't satisfy the first matter. ```vim :echo systemlist('echo hello') " => ['hello'] " `echo` command outputs text with NL, " so this should be ['hello', ''] ``` This change fixes the above problem.
- Loading branch information
Showing
4 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
" Test systemlist() | ||
|
||
let s:dump_cmd = has('win32') ? 'type' : 'cat' | ||
|
||
func! s:systemlist(content) abort | ||
let file = tempname() | ||
call writefile(a:content, file, 'b') | ||
let cmdline = printf('%s %s', s:dump_cmd, shellescape(file)) | ||
call assert_equal(a:content, systemlist(cmdline)) | ||
call delete(file) | ||
endfunc | ||
|
||
func Test_systemlist() | ||
let save_shellslash = &shellslash | ||
set noshellslash " Need for shellescape() | ||
|
||
" empty file | ||
call s:systemlist(['']) | ||
|
||
" noeol file | ||
call s:systemlist(['foo']) | ||
|
||
" eol file | ||
call s:systemlist(['foo', '']) | ||
|
||
let &shellslash = save_shellslash | ||
endfunc |