aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
authormakepost@firemail.cc <makepost@firemail.cc>2019-03-25 23:29:12 -0500
committerRob Landley <rob@landley.net>2019-03-25 23:29:12 -0500
commite954e37fbf92720533f59901513ce50e375c8abf (patch)
treecb1665f8c3cc014f3ba63e04cc70bde12c9eae39 /toys/posix
parent44dd6dd6520430b677ab97e886e8317490f04355 (diff)
downloadtoybox-e954e37fbf92720533f59901513ce50e375c8abf.tar.gz
Add rm -v.
Gentoo removes verbosely when building packages, for example vim-core: https://github.com/gentoo/gentoo/blob/665eaa8/app-editors/vim-core/vim-core-8.1.0648.ebuild#L120 Implement like toy cp, without prepending an escape sign to quotation marks in filenames. Document in a test this difference from coreutils but similarity to busybox. How do other implementations handle such escapes? If it matters, would you approach it with a loop and multiple prints or somehow else? Short help description follows 141a075, consistent with other commands.
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/rm.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/toys/posix/rm.c b/toys/posix/rm.c
index 608e1ca1..6c64e13f 100644
--- a/toys/posix/rm.c
+++ b/toys/posix/rm.c
@@ -4,19 +4,20 @@
*
* See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/rm.html
-USE_RM(NEWTOY(rm, "fiRr[-fi]", TOYFLAG_BIN))
+USE_RM(NEWTOY(rm, "fiRrv[-fi]", TOYFLAG_BIN))
config RM
bool "rm"
default y
help
- usage: rm [-fiRr] FILE...
+ usage: rm [-fiRrv] FILE...
Remove each argument from the filesystem.
-f Force: remove without confirmation, no error if it doesn't exist
-i Interactive: prompt for confirmation
-rR Recursive: remove directory contents
+ -v Verbose
*/
#define FOR_rm
@@ -68,7 +69,13 @@ static int do_rm(struct dirtree *try)
}
skip:
- if (unlinkat(fd, try->name, using)) {
+ if (!unlinkat(fd, try->name, using)) {
+ if (flags & FLAG_v) {
+ char *s = dirtree_path(try, 0);
+ printf("%s%s '%s'\n", toys.which->name, dir ? "dir" : "", s);
+ free(s);
+ }
+ } else {
if (!dir || try->symlink != (char *)2) perror_msg_raw(try->name);
nodelete:
if (try->parent) try->parent->symlink = (char *)2;