diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-09-28 15:51:37 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-09-28 15:51:37 +0200 |
commit | 1a613398068580ca1286ac2ed920f20c978aa662 (patch) | |
tree | 05b183b30f8ee99eea6288e9657f6213e7eacdb7 /src/testdir/test_system.vim | |
parent | 0f1c6708fdf17bb9c7305b8af5d12189956195b6 (diff) | |
download | vim-git-1a613398068580ca1286ac2ed920f20c978aa662.tar.gz |
patch 8.1.2092: MS-Windows: redirect in system() does not workv8.1.2092
Problem: MS-Windows: redirect in system() does not work.
Solution: Handle 'shellxescape' and 'shellxquote' better. (Yasuhiro
Matsumoto, closes #2054)
Diffstat (limited to 'src/testdir/test_system.vim')
-rw-r--r-- | src/testdir/test_system.vim | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/src/testdir/test_system.vim b/src/testdir/test_system.vim index deee51fa1..22aceb707 100644 --- a/src/testdir/test_system.vim +++ b/src/testdir/test_system.vim @@ -3,9 +3,24 @@ source shared.vim func Test_System() - if !executable('echo') || !executable('cat') || !executable('wc') + if !has('win32') + call assert_equal("123\n", system('echo 123')) + call assert_equal(['123'], systemlist('echo 123')) + call assert_equal('123', system('cat', '123')) + call assert_equal(['123'], systemlist('cat', '123')) + call assert_equal(["as\<NL>df"], systemlist('cat', ["as\<NL>df"])) + else + call assert_equal("123\n", system('echo 123')) + call assert_equal(["123\r"], systemlist('echo 123')) + call assert_equal("123", system('more', '123')) + call assert_equal(["123"], systemlist('more', '123')) + call assert_equal(["as\<NL>df"], systemlist('more', ["as\<NL>df"])) + endif + + if !executable('cat') || !executable('wc') return endif + let out = 'echo 123'->system() " On Windows we may get a trailing space. if out != "123 \n" @@ -13,14 +28,17 @@ func Test_System() endif let out = 'echo 123'->systemlist() - " On Windows we may get a trailing space and CR. - if out != ["123 \r"] - call assert_equal(['123'], out) + if !has('win32') + call assert_equal(["123"], out) + else + call assert_equal(["123\r"], out) endif - call assert_equal('123', system('cat', '123')) - call assert_equal(['123'], systemlist('cat', '123')) - call assert_equal(["as\<NL>df"], systemlist('cat', ["as\<NL>df"])) + if executable('cat') + call assert_equal('123', system('cat', '123')) + call assert_equal(['123'], systemlist('cat', '123')) + call assert_equal(["as\<NL>df"], systemlist('cat', ["as\<NL>df"])) + endif new Xdummy call setline(1, ['asdf', "pw\<NL>er", 'xxxx']) @@ -39,9 +57,11 @@ func Test_System() call assert_equal(['3'], out) endif - let out = systemlist('cat', bufnr('%')) - " On Windows we may get a trailing CR. - if out != ["asdf\r", "pw\<NL>er\r", "xxxx\r"] + if !has('win32') + let out = systemlist('cat', bufnr('%')) + call assert_equal(['asdf', "pw\<NL>er", 'xxxx'], out) + else + let out = systemlist('more', bufnr('%')) call assert_equal(['asdf', "pw\<NL>er", 'xxxx'], out) endif bwipe! |