rm: new option --dir (-d) to remove empty directories
authorKrzysztof Goj <krzysztof.goj@gmail.com>
Sun, 22 Jan 2012 00:39:59 +0000 (01:39 +0100)
committerJim Meyering <meyering@redhat.com>
Tue, 14 Aug 2012 16:54:16 +0000 (18:54 +0200)
commitfdc2da7165d93c8065365999341173ad2a818833
tree25ef66176016b61abb71b56175b6cdb42fb54ee4
parent46afefaaa8ea95b5eb63a62792774cd18738234a
rm: new option --dir (-d) to remove empty directories

Add new option to rm (-d/--dir), which allows removal of
empty directories, while still safely disallowing removal
of non-empty ones.

This improves compatibility with Mac OS X and BSD systems,
which honor the -d option.

* src/remove.c (rm_fts): Remove empty directories when requested.
* src/remove.h (rm_options) [remove_empty_directories]: New member.
* src/rm.c (long_opts, usage, main): Update usage and option parsing.
(rm_option_init): Initialize the new member.
* src/mv.c (rm_option_init): Initialize the new member.
* tests/rm/d-1: New test case - successfully delete empty dir.
* tests/rm/d-2: New test case - refuse to delete nonempty dir.
* tests/Makefile.am (TESTS): Add them.
NEWS
doc/coreutils.texi
src/mv.c
src/remove.c
src/remove.h
src/rm.c
tests/Makefile.am
tests/rm/d-1 [new file with mode: 0755]
tests/rm/d-2 [new file with mode: 0755]