summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--parse.c4
-rwxr-xr-xtests.sh23
-rw-r--r--tests/test_delete.out1
-rw-r--r--tests/test_rm.out1
4 files changed, 25 insertions, 4 deletions
diff --git a/parse.c b/parse.c
index 4ffe715..98f603d 100644
--- a/parse.c
+++ b/parse.c
@@ -2156,6 +2156,9 @@ static struct expr *parse_help(struct parser_state *state, int arg1, int arg2) {
cfprintf(cout, " %{blu}-sparse%{rs}\n");
cfprintf(cout, " Find files that occupy fewer disk blocks than expected\n\n");
+ cfprintf(cout, " %{blu}-rm%{rs}\n");
+ cfprintf(cout, " Delete any found files (same as %{blu}-delete%{rs}; implies %{blu}-depth%{rs})\n\n");
+
cfprintf(cout, "%{bld}Extra features:%{rs}\n\n");
cfprintf(cout, " %{blu}-color%{rs}\n");
@@ -2278,6 +2281,7 @@ static const struct table_entry parse_table[] = {
{"-readable", false, parse_access, R_OK},
{"-regex", false, parse_regex, 0},
{"-regextype", false, parse_regextype},
+ {"-rm", false, parse_delete},
{"-samefile", false, parse_samefile},
{"-size", false, parse_size},
{"-sparse", false, parse_sparse},
diff --git a/tests.sh b/tests.sh
index a2b1681..a701e3d 100755
--- a/tests.sh
+++ b/tests.sh
@@ -223,7 +223,8 @@ bsd_tests=(
test_flag_double_dash
test_ok_stdin
test_okdir_stdin
- test_delete_root
+ test_delete
+ test_rm
test_execdir_slash
test_execdir_slash_pwd
test_execdir_slashes
@@ -305,7 +306,7 @@ gnu_tests=(
test_perm_644_slash
test_perm_symbolic_slash
test_perm_leading_plus_symbolic_slash
- test_delete_root
+ test_delete
test_execdir_slash
test_execdir_slash_pwd
test_execdir_slashes
@@ -899,9 +900,23 @@ function test_okdir_stdin() {
yes | bfs_diff basic -okdir bash -c "printf '%s? ' {} && head -n1" \; 2>/dev/null
}
-function test_delete_root() {
+function test_delete() {
+ rm -rf scratch/*
+ touchp scratch/foo/bar/baz
+
# Don't try to delete '.'
- (cd scratch && $BFS . -delete)
+ (cd scratch && $BFS -delete)
+
+ bfs_diff scratch
+}
+
+function test_rm() {
+ rm -rf scratch/*
+ touchp scratch/foo/bar/baz
+
+ (cd scratch && $BFS -rm)
+
+ bfs_diff scratch
}
function test_execdir_slash() {
diff --git a/tests/test_delete.out b/tests/test_delete.out
new file mode 100644
index 0000000..fb188b9
--- /dev/null
+++ b/tests/test_delete.out
@@ -0,0 +1 @@
+scratch
diff --git a/tests/test_rm.out b/tests/test_rm.out
new file mode 100644
index 0000000..fb188b9
--- /dev/null
+++ b/tests/test_rm.out
@@ -0,0 +1 @@
+scratch