@@ -48,42 +48,45 @@ function! Test_System()
4848endfunction
4949
5050function ! Test_system_exmode ()
51- if ! has (' unix' )
52- return
51+ if has (' unix' ) " echo $? only works on Unix
52+ let cmd = ' -es -u NONE -c "source Xscript" +q; echo $?'
53+ " Need to put this in a script, "catch" isn't found after an unknown
54+ " function.
55+ call writefile ([' try' , ' call doesnotexist()' , ' catch' , ' endtry' ], ' Xscript' )
56+ let a = system (v: progpath . cmd)
57+ call assert_equal (' 0' , a [0 ])
58+ call assert_equal (0 , v: shell_error )
5359 endif
5460
55- let cmd= " -es -u NONE -c 'source Xscript' +q; echo $?"
56- " Need to put this in a script, "catch" isn't found after an unknown
57- " function.
58- call writefile ([' try' , ' call doesnotexist()' , ' catch' , ' endtry' ], ' Xscript' )
59- let a = system (v: progpath . cmd)
60- call assert_equal (' 0' , a [0 ])
61- call assert_equal (0 , v: shell_error )
62-
6361 " Error before try does set error flag.
6462 call writefile ([' call nosuchfunction()' , ' try' , ' call doesnotexist()' , ' catch' , ' endtry' ], ' Xscript' )
65- let a = system (v: progpath . cmd)
66- call assert_notequal (' 0' , a [0 ])
63+ if has (' unix' ) " echo $? only works on Unix
64+ let a = system (v: progpath . cmd)
65+ call assert_notequal (' 0' , a [0 ])
66+ endif
6767
68- let cmd= " -es -u NONE -c ' source Xscript' +q"
68+ let cmd = ' -es -u NONE -c " source Xscript" +q'
6969 let a = system (v: progpath . cmd)
7070 call assert_notequal (0 , v: shell_error )
71+ call delete (' Xscript' )
7172
72- let cmd= " -es -u NONE -c 'call doesnotexist()' +q; echo $?"
73- let a = system (v: progpath . cmd)
74- call assert_notequal (0 , a [0 ])
73+ if has (' unix' ) " echo $? only works on Unix
74+ let cmd = ' -es -u NONE -c "call doesnotexist()" +q; echo $?'
75+ let a = system (v: progpath . cmd)
76+ call assert_notequal (0 , a [0 ])
77+ endif
7578
76- let cmd= " -es -u NONE -c ' call doesnotexist()' +q"
79+ let cmd = ' -es -u NONE -c " call doesnotexist()" +q'
7780 let a = system (v: progpath . cmd)
7881 call assert_notequal (0 , v: shell_error )
7982
80- let cmd= " -es -u NONE -c 'call doesnotexist()|let a=1' +q; echo $?"
81- let a = system (v: progpath . cmd)
82- call assert_notequal (0 , a [0 ])
83+ if has (' unix' ) " echo $? only works on Unix
84+ let cmd = ' -es -u NONE -c "call doesnotexist()|let a=1" +q; echo $?'
85+ let a = system (v: progpath . cmd)
86+ call assert_notequal (0 , a [0 ])
87+ endif
8388
84- let cmd= " -es -u NONE -c ' call doesnotexist()|let a=1' +q"
89+ let cmd = ' -es -u NONE -c " call doesnotexist()|let a=1" +q'
8590 let a = system (v: progpath . cmd)
8691 call assert_notequal (0 , v: shell_error )
87-
88- call delete (' Xscript' )
8992endfunc
0 commit comments