diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2017-07-20 23:14:48 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2017-07-20 23:26:02 -0400 |
commit | 03adbcf0aa8914fd5556b7913901c98a6940fae4 (patch) | |
tree | 03b085bae5ae82d5802990f1c63232df5c1449b6 | |
parent | 3a94d05833019023636bc8ac55a686f4fa8cf3d8 (diff) | |
download | bfs-03adbcf0aa8914fd5556b7913901c98a6940fae4.tar.xz |
Implement -rm as an alias for -delete
From NetBSD.
-rw-r--r-- | parse.c | 4 | ||||
-rwxr-xr-x | tests.sh | 23 | ||||
-rw-r--r-- | tests/test_delete.out | 1 | ||||
-rw-r--r-- | tests/test_rm.out | 1 |
4 files changed, 25 insertions, 4 deletions
@@ -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}, @@ -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 |