annotate src/testdir/test_system.vim @ 32033:5bf9832d3e00 v9.0.1348

patch 9.0.1348: Un-grammar files are not recognized Commit: https://github.com/vim/vim/commit/44e08c1cf83f5a50f8b21613551304a6651c1161 Author: Amaan Qureshi <amaanq12@gmail.com> Date: Thu Feb 23 20:31:08 2023 +0000 patch 9.0.1348: Un-grammar files are not recognized Problem: Un-grammar files are not recognized. Solution: Add patterns for Un-grammar files. (Amaan Qureshi, closes https://github.com/vim/vim/issues/12034)
author Bram Moolenaar <Bram@vim.org>
date Thu, 23 Feb 2023 21:45:03 +0100
parents ae10b91ac6b3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10522
7232cd9f8a7c commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for system() and systemlist()
7232cd9f8a7c commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
3 source shared.vim
18241
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
4 source check.vim
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
5
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11637
diff changeset
6 func Test_System()
18195
a81f0c936112 patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
7 if !has('win32')
a81f0c936112 patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
8 call assert_equal("123\n", system('echo 123'))
a81f0c936112 patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
9 call assert_equal(['123'], systemlist('echo 123'))
a81f0c936112 patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
10 call assert_equal('123', system('cat', '123'))
a81f0c936112 patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
11 call assert_equal(['123'], systemlist('cat', '123'))
a81f0c936112 patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
12 call assert_equal(["as\<NL>df"], systemlist('cat', ["as\<NL>df"]))
a81f0c936112 patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
13 else
a81f0c936112 patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
14 call assert_equal("123\n", system('echo 123'))
a81f0c936112 patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
15 call assert_equal(["123\r"], systemlist('echo 123'))
21451
756562af426e patch 8.2.1276: MS-Windows: system test may fail if more.exe is installed
Bram Moolenaar <Bram@vim.org>
parents: 20313
diff changeset
16 call assert_equal("123\n", system('more.com', '123'))
756562af426e patch 8.2.1276: MS-Windows: system test may fail if more.exe is installed
Bram Moolenaar <Bram@vim.org>
parents: 20313
diff changeset
17 call assert_equal(["123\r"], systemlist('more.com', '123'))
756562af426e patch 8.2.1276: MS-Windows: system test may fail if more.exe is installed
Bram Moolenaar <Bram@vim.org>
parents: 20313
diff changeset
18 call assert_equal(["as\r", "df\r"], systemlist('more.com', ["as\<NL>df"]))
18195
a81f0c936112 patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
19 endif
a81f0c936112 patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
20
10522
7232cd9f8a7c commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 new Xdummy
7232cd9f8a7c commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 call setline(1, ['asdf', "pw\<NL>er", 'xxxx'])
18473
0eeaa9a6e4e7 patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents: 18241
diff changeset
23
0eeaa9a6e4e7 patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents: 18241
diff changeset
24 if executable('wc')
0eeaa9a6e4e7 patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents: 18241
diff changeset
25 let out = system('wc -l', bufnr('%'))
0eeaa9a6e4e7 patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents: 18241
diff changeset
26 " On OS/X we get leading spaces
0eeaa9a6e4e7 patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents: 18241
diff changeset
27 let out = substitute(out, '^ *', '', '')
0eeaa9a6e4e7 patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents: 18241
diff changeset
28 call assert_equal("3\n", out)
10526
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
29
18473
0eeaa9a6e4e7 patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents: 18241
diff changeset
30 let out = systemlist('wc -l', bufnr('%'))
0eeaa9a6e4e7 patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents: 18241
diff changeset
31 " On Windows we may get a trailing CR.
0eeaa9a6e4e7 patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents: 18241
diff changeset
32 if out != ["3\r"]
0eeaa9a6e4e7 patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents: 18241
diff changeset
33 " On OS/X we get leading spaces
0eeaa9a6e4e7 patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents: 18241
diff changeset
34 if type(out) == v:t_list
0eeaa9a6e4e7 patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents: 18241
diff changeset
35 let out[0] = substitute(out[0], '^ *', '', '')
0eeaa9a6e4e7 patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents: 18241
diff changeset
36 endif
0eeaa9a6e4e7 patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents: 18241
diff changeset
37 call assert_equal(['3'], out)
10528
3ea703795a4f commit https://github.com/vim/vim/commit/31f19ce0a052f7c76d44a9a190e468c79cf5d56d
Christian Brabandt <cb@256bit.org>
parents: 10526
diff changeset
38 endif
10526
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
39 endif
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
40
18195
a81f0c936112 patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
41 if !has('win32')
a81f0c936112 patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
42 let out = systemlist('cat', bufnr('%'))
a81f0c936112 patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
43 call assert_equal(['asdf', "pw\<NL>er", 'xxxx'], out)
a81f0c936112 patch 8.1.2092: MS-Windows: redirect in system() does not work
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
44 else
21451
756562af426e patch 8.2.1276: MS-Windows: system test may fail if more.exe is installed
Bram Moolenaar <Bram@vim.org>
parents: 20313
diff changeset
45 let out = systemlist('more.com', bufnr('%'))
18197
78d4902b22df patch 8.1.2093: MS-Windows: system() test fails
Bram Moolenaar <Bram@vim.org>
parents: 18195
diff changeset
46 call assert_equal(["asdf\r", "pw\r", "er\r", "xxxx\r"], out)
10526
06724e21d8c1 commit https://github.com/vim/vim/commit/9d9c35651712b88c81f1ae11091de1fd0bbbd35c
Christian Brabandt <cb@256bit.org>
parents: 10522
diff changeset
47 endif
10522
7232cd9f8a7c commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 bwipe!
7232cd9f8a7c commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49
7232cd9f8a7c commit https://github.com/vim/vim/commit/12c4492dd35e0cd83c8816be2ec849b836109882
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 call assert_fails('call system("wc -l", 99999)', 'E86:')
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11637
diff changeset
51 endfunc
10589
b0c9c1a05054 patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents: 10528
diff changeset
52
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 11637
diff changeset
53 func Test_system_exmode()
10615
de4aae865134 patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10591
diff changeset
54 if has('unix') " echo $? only works on Unix
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
55 let cmd = ' -es -c "source Xscript" +q; echo "result=$?"'
10615
de4aae865134 patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10591
diff changeset
56 " Need to put this in a script, "catch" isn't found after an unknown
de4aae865134 patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10591
diff changeset
57 " function.
30769
ae10b91ac6b3 patch 9.0.0719: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 25048
diff changeset
58 call writefile(['try', 'call doesnotexist()', 'catch', 'endtry'], 'Xscript', 'D')
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
59 let a = system(GetVimCommand() . cmd)
11637
bcab4e804c20 patch 8.0.0701: system test failing when using X11 forwarding
Christian Brabandt <cb@256bit.org>
parents: 10615
diff changeset
60 call assert_match('result=0', a)
10615
de4aae865134 patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10591
diff changeset
61 call assert_equal(0, v:shell_error)
10591
234da476c4fd patch 8.0.0185: system() test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10589
diff changeset
62 endif
234da476c4fd patch 8.0.0185: system() test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10589
diff changeset
63
10589
b0c9c1a05054 patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents: 10528
diff changeset
64 " Error before try does set error flag.
b0c9c1a05054 patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents: 10528
diff changeset
65 call writefile(['call nosuchfunction()', 'try', 'call doesnotexist()', 'catch', 'endtry'], 'Xscript')
10615
de4aae865134 patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10591
diff changeset
66 if has('unix') " echo $? only works on Unix
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
67 let a = system(GetVimCommand() . cmd)
10615
de4aae865134 patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10591
diff changeset
68 call assert_notequal('0', a[0])
de4aae865134 patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10591
diff changeset
69 endif
10589
b0c9c1a05054 patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents: 10528
diff changeset
70
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
71 let cmd = ' -es -c "source Xscript" +q'
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
72 let a = system(GetVimCommand() . cmd)
10589
b0c9c1a05054 patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents: 10528
diff changeset
73 call assert_notequal(0, v:shell_error)
b0c9c1a05054 patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents: 10528
diff changeset
74
10615
de4aae865134 patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10591
diff changeset
75 if has('unix') " echo $? only works on Unix
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
76 let cmd = ' -es -c "call doesnotexist()" +q; echo $?'
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
77 let a = system(GetVimCommand() . cmd)
10615
de4aae865134 patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10591
diff changeset
78 call assert_notequal(0, a[0])
de4aae865134 patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10591
diff changeset
79 endif
10589
b0c9c1a05054 patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents: 10528
diff changeset
80
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
81 let cmd = ' -es -c "call doesnotexist()" +q'
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
82 let a = system(GetVimCommand(). cmd)
10589
b0c9c1a05054 patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents: 10528
diff changeset
83 call assert_notequal(0, v:shell_error)
b0c9c1a05054 patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents: 10528
diff changeset
84
10615
de4aae865134 patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10591
diff changeset
85 if has('unix') " echo $? only works on Unix
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
86 let cmd = ' -es -c "call doesnotexist()|let a=1" +q; echo $?'
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
87 let a = system(GetVimCommand() . cmd)
10615
de4aae865134 patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10591
diff changeset
88 call assert_notequal(0, a[0])
de4aae865134 patch 8.0.0197: system() test skips some parts for MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10591
diff changeset
89 endif
10589
b0c9c1a05054 patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents: 10528
diff changeset
90
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
91 let cmd = ' -es -c "call doesnotexist()|let a=1" +q'
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
92 let a = system(GetVimCommand() . cmd)
10589
b0c9c1a05054 patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents: 10528
diff changeset
93 call assert_notequal(0, v:shell_error)
b0c9c1a05054 patch 8.0.0184: when an error is caught Vim still exits with non-zero result
Christian Brabandt <cb@256bit.org>
parents: 10528
diff changeset
94 endfunc
18241
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
95
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
96 func Test_system_with_shell_quote()
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
97 CheckMSWindows
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
98
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
99 call mkdir('Xdir with spaces', 'p')
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
100 call system('copy "%COMSPEC%" "Xdir with spaces\cmd.exe"')
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
101
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
102 let shell_save = &shell
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
103 let shellxquote_save = &shellxquote
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
104 try
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
105 " Set 'shell' always needs noshellslash.
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
106 let shellslash_save = &shellslash
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
107 set noshellslash
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
108 let shell_tests = [
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
109 \ expand('$COMSPEC'),
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
110 \ '"' . fnamemodify('Xdir with spaces\cmd.exe', ':p') . '"',
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
111 \]
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
112 let &shellslash = shellslash_save
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
113
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
114 let sxq_tests = ['', '(', '"']
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
115
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
116 " Matrix tests: 'shell' * 'shellxquote'
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
117 for shell in shell_tests
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
118 let &shell = shell
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
119 for sxq in sxq_tests
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
120 let &shellxquote = sxq
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
121
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
122 let msg = printf('shell=%s shellxquote=%s', &shell, &shellxquote)
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
123
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
124 try
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
125 let out = 'echo 123'->system()
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
126 catch
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
127 call assert_report(printf('%s: %s', msg, v:exception))
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
128 continue
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
129 endtry
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
130
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
131 " On Windows we may get a trailing space and CR.
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
132 if out != "123 \n"
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
133 call assert_equal("123\n", out, msg)
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
134 endif
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
135
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
136 endfor
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
137 endfor
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
138
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
139 finally
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
140 let &shell = shell_save
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
141 let &shellxquote = shellxquote_save
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
142 call delete('Xdir with spaces', 'rf')
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
143 endtry
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18197
diff changeset
144 endfunc
20313
244eb8d8d100 patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
145
244eb8d8d100 patch 8.2.0712: various code not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
146 " vim: shiftwidth=2 sts=2 expandtab