diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-11-09 20:10:17 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-11-09 20:10:17 +0100 |
commit | 3503d7c94a6c8c2a5ca1665d648d0cb81afcc863 (patch) | |
tree | 1084785735f6ed7f60ef12045d016977ae92c377 /src | |
parent | b73e439606b55d66d9e81da1f9cae729af37cf04 (diff) |
patch 8.1.2278: using "cd" with "exe" may failv8.1.2278
Problem: Using "cd" with "exe" may fail.
Solution: Use chdir() instead.
Diffstat (limited to 'src')
-rw-r--r-- | src/testdir/test_autochdir.vim | 2 | ||||
-rw-r--r-- | src/testdir/test_autocmd.vim | 16 | ||||
-rw-r--r-- | src/testdir/test_cd.vim | 8 | ||||
-rw-r--r-- | src/testdir/test_expand.vim | 2 | ||||
-rw-r--r-- | src/testdir/test_find_complete.vim | 8 | ||||
-rw-r--r-- | src/testdir/test_findfile.vim | 4 | ||||
-rw-r--r-- | src/testdir/test_getcwd.vim | 2 | ||||
-rw-r--r-- | src/testdir/test_shortpathname.vim | 4 | ||||
-rw-r--r-- | src/version.c | 2 |
9 files changed, 25 insertions, 23 deletions
diff --git a/src/testdir/test_autochdir.vim b/src/testdir/test_autochdir.vim index 98d1af74fd..1473854c97 100644 --- a/src/testdir/test_autochdir.vim +++ b/src/testdir/test_autochdir.vim @@ -21,6 +21,6 @@ func Test_set_filename() bwipe! au! DirChanged set noacd - exe 'cd ' . cwd + call chdir(cwd) call delete('samples/Xtest') endfunc diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim index 1e53fe4639..13febb0a85 100644 --- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -1731,7 +1731,7 @@ function s:Before_test_dirchanged() endfunc function s:After_test_dirchanged() - exe 'cd' s:dir_this + call chdir(s:dir_this) call delete(s:dir_foo, 'd') call delete(s:dir_bar, 'd') augroup test_dirchanged @@ -1743,11 +1743,11 @@ function Test_dirchanged_global() call s:Before_test_dirchanged() autocmd test_dirchanged DirChanged global call add(s:li, "cd:") autocmd test_dirchanged DirChanged global call add(s:li, expand("<afile>")) - exe 'cd' s:dir_foo + call chdir(s:dir_foo) call assert_equal(["cd:", s:dir_foo], s:li) - exe 'cd' s:dir_foo + call chdir(s:dir_foo) call assert_equal(["cd:", s:dir_foo], s:li) - exe 'lcd' s:dir_bar + exe 'lcd ' .. fnameescape(s:dir_bar) call assert_equal(["cd:", s:dir_foo], s:li) call s:After_test_dirchanged() endfunc @@ -1756,11 +1756,11 @@ function Test_dirchanged_local() call s:Before_test_dirchanged() autocmd test_dirchanged DirChanged window call add(s:li, "lcd:") autocmd test_dirchanged DirChanged window call add(s:li, expand("<afile>")) - exe 'cd' s:dir_foo + call chdir(s:dir_foo) call assert_equal([], s:li) - exe 'lcd' s:dir_bar + exe 'lcd ' .. fnameescape(s:dir_bar) call assert_equal(["lcd:", s:dir_bar], s:li) - exe 'lcd' s:dir_bar + exe 'lcd ' .. fnameescape(s:dir_bar) call assert_equal(["lcd:", s:dir_bar], s:li) call s:After_test_dirchanged() endfunc @@ -1774,7 +1774,7 @@ function Test_dirchanged_auto() autocmd test_dirchanged DirChanged auto call add(s:li, "auto:") autocmd test_dirchanged DirChanged auto call add(s:li, expand("<afile>")) set acd - exe 'cd ..' + cd .. call assert_equal([], s:li) exe 'edit ' . s:dir_foo . '/Xfile' call assert_equal(s:dir_foo, getcwd()) diff --git a/src/testdir/test_cd.vim b/src/testdir/test_cd.vim index c3589b45f0..bdb26cddce 100644 --- a/src/testdir/test_cd.vim +++ b/src/testdir/test_cd.vim @@ -9,7 +9,7 @@ func Test_cd_up_and_down() let path = getcwd() cd .. call assert_notequal(path, getcwd()) - exe 'cd ' . path + exe 'cd ' .. fnameescape(path) call assert_equal(path, getcwd()) endfunc @@ -20,7 +20,7 @@ func Test_cd_no_arg() cd call assert_equal($HOME, getcwd()) call assert_notequal(path, getcwd()) - exe 'cd ' . path + exe 'cd ' .. fnameescape(path) call assert_equal(path, getcwd()) else " Test that cd without argument echoes cwd on non-Unix systems. @@ -58,7 +58,7 @@ func Test_cd_with_cpo_chdir() " :cd should succeed when buffer has been written. w! - exe 'cd ' . path + exe 'cd ' .. fnameescape(path) call assert_equal(path, getcwd()) call delete('Xfoo') @@ -103,6 +103,6 @@ func Test_chdir_func() call assert_equal("", d) only | tabonly - exe 'cd ' . topdir + call chdir(topdir) call delete('Xdir', 'rf') endfunc diff --git a/src/testdir/test_expand.vim b/src/testdir/test_expand.vim index 53f753d3f8..48dce25bb3 100644 --- a/src/testdir/test_expand.vim +++ b/src/testdir/test_expand.vim @@ -35,7 +35,7 @@ func Test_with_tilde() call assert_true(isdirectory('Xdir ~ dir')) cd Xdir\ ~\ dir call assert_true(getcwd() =~ 'Xdir \~ dir') - exe 'cd ' . fnameescape(dir) + call chdir(dir) call delete('Xdir ~ dir', 'd') call assert_false(isdirectory('Xdir ~ dir')) endfunc diff --git a/src/testdir/test_find_complete.vim b/src/testdir/test_find_complete.vim index a7bc135d47..679bf3c200 100644 --- a/src/testdir/test_find_complete.vim +++ b/src/testdir/test_find_complete.vim @@ -36,7 +36,7 @@ func Test_find_complete() " We shouldn't find any file till this point call mkdir('in/path', 'p') - exe 'cd ' . cwd + call chdir(cwd) call writefile(['Holy Grail'], 'Xfind/file.txt') call writefile(['Jimmy Hoffa'], 'Xfind/in/file.txt') call writefile(['Another Holy Grail'], 'Xfind/in/stuff.txt') @@ -133,12 +133,12 @@ func Test_find_complete() call assert_equal('Voyager 2', getline(1)) " Check for correct handling of shorten_fname()'s behavior on windows - exec "cd " . cwd . "/Xfind/in" + call chdir(cwd .. "/Xfind/in") call feedkeys(":find file\t\n", "xt") call assert_equal('Jimmy Hoffa', getline(1)) " Test for relative to current buffer 'path' item - exec "cd " . cwd . "/Xfind/" + call chdir(cwd . "/Xfind/") set path=./path " Open the file where Jimmy Hoffa is found e in/file.txt @@ -157,7 +157,7 @@ func Test_find_complete() call assert_equal('Another Holy Grail', getline(1)) enew | only - exe 'cd ' . cwd + call chdir(cwd) call delete('Xfind', 'rf') set path& endfunc diff --git a/src/testdir/test_findfile.vim b/src/testdir/test_findfile.vim index 5cda2ea821..2e6f888896 100644 --- a/src/testdir/test_findfile.vim +++ b/src/testdir/test_findfile.vim @@ -113,7 +113,7 @@ func Test_findfile() call assert_match('.*/Xdir1/bar', findfile('bar', '**;', 2)) bwipe! - exe 'cd ' . save_dir + call chdir(save_dir) call CleanFiles() let &path = save_path let &shellslash = save_shellslash @@ -170,7 +170,7 @@ func Test_finddir() call assert_match('.*/Xdir1/Xdir2', finddir('Xdir2', '**;', 2)) call assert_equal('Xdir3', finddir('Xdir3', '**;', 1)) - exe 'cd ' . save_dir + call chdir(save_dir) call CleanFiles() let &path = save_path let &shellslash = save_shellslash diff --git a/src/testdir/test_getcwd.vim b/src/testdir/test_getcwd.vim index b1470d76b7..e87f693c2c 100644 --- a/src/testdir/test_getcwd.vim +++ b/src/testdir/test_getcwd.vim @@ -46,7 +46,7 @@ endfunction let g:cwd=getcwd() function TearDown() q - exec "cd " . g:cwd + call chdir(g:cwd) call delete("Xtopdir", "rf") endfunction diff --git a/src/testdir/test_shortpathname.vim b/src/testdir/test_shortpathname.vim index 6b3f85f181..3c09b4c25d 100644 --- a/src/testdir/test_shortpathname.vim +++ b/src/testdir/test_shortpathname.vim @@ -51,7 +51,7 @@ func Test_ColonEight() call TestIt(file2, ':p:8', resfile2) call TestIt(nofile2, ':p:8', resnofile2) call TestIt(nofile2, ':p:8:h', fnamemodify(resnofile2, ':h')) - exe 'cd ' . dir1 + call chdir(dir1) call TestIt(file1, ':.:8', strpart(resfile1, strlen(resdir1)+1)) call TestIt(nofile1, ':.:8', strpart(resnofile1, strlen(resdir1)+1)) call TestIt(file2, ':.:8', strpart(resfile2, strlen(resdir1)+1)) @@ -68,7 +68,7 @@ func Test_ColonEight() call delete(dir2, 'd') call delete(dir1, 'd') - exe "cd " . save_dir + call chdir(save_dir) endfunc func Test_ColonEight_MultiByte() diff --git a/src/version.c b/src/version.c index bb783f86db..1ab0144dd6 100644 --- a/src/version.c +++ b/src/version.c @@ -742,6 +742,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2278, +/**/ 2277, /**/ 2276, |