1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Backport the ksh93v- rm builtin to fix 'rm -d' (#348)

The -d flag implemented in the rm builtin is completely broken. No
matter what you do it refuses to remove directories, even if -r is
also passed. Reproducer:

  $ mkdir /tmp/empty
  $ PATH=/opt/ast/bin rm -d /tmp/empty
  rm: /tmp/empty: directory
  $ PATH=/opt/ast/bin rm -dr /tmp/empty
  rm: /tmp/empty: directory not removed [Is a directory]

Additionally, the description of 'rm -d' in the man page contradicts
how it's specified in <https://www.austingroupbugs.net/view.php?id=802>.

The ksh93v- rm builtin fixed nearly all of these issues, so I've
backported it to 93u+m and applied one additional fix for 'rm -rd'.

src/lib/libcmd/rm.c:
- Backported the fixes from the ksh93v- rm builtin's -d flag when
  used on empty directories.
- Backported the man page update for rm(1) from ksh93v-.
- The ksh93v- rm builtin had one additional bug that caused the -r
  option to fail when combined with -d. This was fixed by
  overriding -d if -r is also passed.

src/cmd/ksh93/tests/builtins.sh:
- Add regression tests for the rm builtin's -d option.
This commit is contained in:
Johnothan King 2021-11-24 18:45:21 -08:00 committed by Martijn Dekker
parent 2d65148fad
commit 84ded2d0c4
3 changed files with 63 additions and 14 deletions

5
NEWS
View file

@ -9,6 +9,11 @@ Any uppercase BUG_* names are modernish shell bug IDs.
looking up functions defined with the 'function' keyword. In the POSIX
standard and on other shells, the '.' command finds only script files.
- The rm built-in's -d/--directory option has been fixed. It now properly
removes empty directories and refuses to remove non-empty directories
(as specified in https://www.austingroupbugs.net/view.php?id=802). Note
that the rm built-in command isn't compiled in by default.
2021-11-23:
- A bug was fixed that allowed arithmetic expressions to assign out-of-range