Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/testdir/test_system.vim
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,42 @@ func Test_system_with_shell_quote()
endtry
endfunc

" Check that Vim does not execute anything from current directory
func Test_windows_external_cmd_in_cwd()
CheckMSWindows

" just in case
call system('rd /S /Q Xfolder')
call mkdir('Xfolder', 'R')
cd Xfolder

let contents = ['@echo off', 'echo filename1.txt:1:AAAA']
call writefile(contents, 'findstr.cmd')

let file1 = ['AAAA', 'THIS FILE SHOULD NOT BE FOUND']
let file2 = ['BBBB', 'THIS FILE SHOULD BE FOUND']

call writefile(file1, 'filename1.txt')
call writefile(file2, 'filename2.txt')

if has('quickfix')
" use silent to avoid hit-enter-prompt
sil grep BBBB filename*.txt
call assert_equal('filename2.txt', @%)
endif

let output = system('findstr BBBB filename*')
" Match trailing newline byte
call assert_match('filename2.txt:BBBB.', output)

if has('gui')
set guioptions+=!
let output = system('findstr BBBB filename*')
call assert_match('filename2.txt:BBBB.', output)
endif

cd -
set guioptions&
endfunc

" vim: shiftwidth=2 sts=2 expandtab
36 changes: 0 additions & 36 deletions src/testdir/test_terminal2.vim
Original file line number Diff line number Diff line change
Expand Up @@ -740,40 +740,4 @@ func Test_term_gettty()
exe buf . 'bwipe'
endfunc

func Test_windows_external_cmd_in_cwd()
" Check that Vim does not execute anything from current directory
CheckMSWindows

" just in case
call system('rd /S /Q Xfolder')
call mkdir('Xfolder', 'R')
cd Xfolder

let contents = ['@echo off', 'echo filename1.txt:1:AAAA']
call writefile(contents, 'findstr.cmd')

let file1 = ['AAAA', 'THIS FILE SHOULD NOT BE FOUND']
let file2 = ['BBBB', 'THIS FILE SHOULD BE FOUND']

call writefile(file1, 'filename1.txt')
call writefile(file2, 'filename2.txt')

" use silent to avoid hit-enter-prompt
sil grep BBBB filename*.txt

call assert_equal('filename2.txt', @%)

let output = system('findstr BBBB filename*')
" Match trailing newline byte
call assert_match('filename2.txt:BBBB.', output)

set guioptions+=!

let output = system('findstr BBBB filename*')
call assert_match('filename2.txt:BBBB.', output)

cd -
set guioptions&
endfunc

" vim: shiftwidth=2 sts=2 expandtab
Loading