]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0483: glob() not sufficiently tested v9.1.0483
authorChristian Brabandt <cb@256bit.org>
Thu, 13 Jun 2024 19:20:20 +0000 (21:20 +0200)
committerChristian Brabandt <cb@256bit.org>
Thu, 13 Jun 2024 19:20:20 +0000 (21:20 +0200)
Problem:  glob() not sufficiently tested
Solution: Add more tests for directory containing [] chars

related: #14991

Signed-off-by: Christian Brabandt <cb@256bit.org>
src/testdir/test_functions.vim
src/version.c

index fd82801e65208471e00b7cf0e43ee6b1f03a33f4..acdb9544fd62b4ce6498056e56b6a35d551ef089 100644 (file)
@@ -3795,6 +3795,33 @@ func Test_glob()
   call assert_fails("call glob('*', 0, {})", 'E728:')
 endfunc
 
+func Test_glob2()
+  call mkdir('[XglobDir]', 'R')
+  call mkdir('abc[glob]def', 'R')
+
+  call writefile(['glob'], '[XglobDir]/Xglob')
+  call writefile(['glob'], 'abc[glob]def/Xglob')
+  if has("unix")
+    call assert_equal([], (glob('[XglobDir]/*', 0, 1)))
+    call assert_equal([], (glob('abc[glob]def/*', 0, 1)))
+    call assert_equal(['[XglobDir]/Xglob'], (glob('\[XglobDir]/*', 0, 1)))
+    call assert_equal(['abc[glob]def/Xglob'], (glob('abc\[glob]def/*', 0, 1)))
+  elseif has("win32")
+    let _sl=&shellslash
+    call assert_equal([], (glob('[XglobDir]\*', 0, 1)))
+    call assert_equal([], (glob('abc[glob]def\*', 0, 1)))
+    call assert_equal([], (glob('\[XglobDir]\*', 0, 1)))
+    call assert_equal([], (glob('abc\[glob]def\*', 0, 1)))
+    set noshellslash
+    call assert_equal(['[XglobDir]\Xglob'], (glob('[[]XglobDir]/*', 0, 1)))
+    call assert_equal(['abc[glob]def\Xglob'], (glob('abc[[]glob]def/*', 0, 1)))
+    set shellslash
+    call assert_equal(['[XglobDir]/Xglob'], (glob('[[]XglobDir]/*', 0, 1)))
+    call assert_equal(['abc[glob]def/Xglob'], (glob('abc[[]glob]def/*', 0, 1)))
+    let &shellslash=_sl
+  endif
+endfunc
+
 " Test for browse()
 func Test_browse()
   CheckFeature browse
index 43a09d308b7f804411378ae8dc518b5fe6947311..2df207108567314a16e010d85908b53a1f528917 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    483,
 /**/
     482,
 /**/