Skip to content

Commit 336bd62

Browse files
committed
patch 7.4.1120
Problem: delete(x, 'rf') fails if a directory is empty. (Lcd) Solution: Ignore not finding matches in an empty directory.
1 parent 72defda commit 336bd62

File tree

5 files changed

+7
-2
lines changed

5 files changed

+7
-2
lines changed

src/fileio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7313,7 +7313,7 @@ delete_recursive(char_u *name)
73137313
if (exp == NULL)
73147314
return -1;
73157315
if (gen_expand_wildcards(1, &exp, &file_count, &files,
7316-
EW_DIR|EW_FILE|EW_SILENT|EW_ALLLINKS|EW_DODOT) == OK)
7316+
EW_DIR|EW_FILE|EW_SILENT|EW_ALLLINKS|EW_DODOT|EW_EMPTYOK) == OK)
73177317
{
73187318
for (i = 0; i < file_count; ++i)
73197319
if (delete_recursive(files[i]) != 0)

src/misc1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11087,7 +11087,7 @@ gen_expand_wildcards(num_pat, pat, num_file, file, flags)
1108711087

1108811088
recursive = FALSE;
1108911089

11090-
return (ga.ga_data != NULL) ? retval : FAIL;
11090+
return ((flags & EW_EMPTYOK) || ga.ga_data != NULL) ? retval : FAIL;
1109111091
}
1109211092

1109311093
# ifdef VIM_BACKTICK

src/testdir/test_delete.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ endfunc
2121
func Test_recursive_delete()
2222
call mkdir('Xdir1')
2323
call mkdir('Xdir1/subdir')
24+
call mkdir('Xdir1/empty')
2425
split Xdir1/Xfile
2526
call setline(1, ['a', 'b'])
2627
w
@@ -30,6 +31,7 @@ func Test_recursive_delete()
3031
call assert_equal(['a', 'b'], readfile('Xdir1/Xfile'))
3132
call assert_true(isdirectory('Xdir1/subdir'))
3233
call assert_equal(['a', 'b'], readfile('Xdir1/subdir/Xfile'))
34+
call assert_true(isdirectory('Xdir1/empty'))
3335
call assert_equal(0, delete('Xdir1', 'rf'))
3436
call assert_false(isdirectory('Xdir1'))
3537
call assert_equal(-1, delete('Xdir1', 'd'))

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
1120,
744746
/**/
745747
1119,
746748
/**/

src/vim.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,7 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname);
836836
#define EW_SHELLCMD 0x2000 /* called from expand_shellcmd(), don't check
837837
* if executable is in $PATH */
838838
#define EW_DODOT 0x4000 /* also files starting with a dot */
839+
#define EW_EMPTYOK 0x8000 /* no matches is not an error */
839840

840841
/* Flags for find_file_*() functions. */
841842
#define FINDFILE_FILE 0 /* only files */

0 commit comments

Comments
 (0)