diff --git a/visidata/modify.py b/visidata/modify.py index d1024b5ce..cf77b2730 100644 --- a/visidata/modify.py +++ b/visidata/modify.py @@ -139,8 +139,11 @@ def deleteBy(sheet, func, commit=False, undo=True): if r is newCursorRow: sheet.cursorRowIndex = len(sheet.rows)-1 else: - sheet.commitDeleteRow(r) - ndeleted += 1 + try: + sheet.commitDeleteRow(r) + ndeleted += 1 + except Exception as e: + vd.exceptionCaught(e) if undo: vd.addUndo(setattr, sheet, 'rows', oldrows) diff --git a/visidata/shell.py b/visidata/shell.py index 0f09b0328..13885b240 100644 --- a/visidata/shell.py +++ b/visidata/shell.py @@ -165,7 +165,10 @@ def renameFile(self, row, val): def removeFile(self, path): if path.is_dir(): - os.rmdir(path) + if self.options.safety_first: + os.rmdir(path) + else: + shutil.rmtree(path) #1965 else: path.unlink()