aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/rm.c
AgeCommit message (Collapse)Author
2021-02-01Minor tweak.Rob Landley
2021-02-01rm: Check file existence with lstat() explicitly if "-f" is specifiedYi-Yo Chiang
Instead of unlink() && check errno, call lstat() explicitly to check file existence if "-f" is specified. There is a regression when if the path to be removed is nonexistence and within a readonly filesystem, then unlink() could set the EROFS errno instead of ENOENT, thus screwing up the output of `rm`.
2020-01-28David Legault complained that dir/.* tells rm to delete dir/.. and we'd do it.Rob Landley
2019-11-12Don't rm prompt for nonexistent, just warn.Denys Nykula
2019-09-20rm.c: use FLAG().Elliott Hughes
2019-08-23rm: error message consistency.Elliott Hughes
Before: $ ./rm rm: Needs 1 argument $ ./rmdir rmdir: Needs 1 argument (see "rmdir --help") After: $ ./rm rm: Needs 1 argument (see "rm --help")
2019-03-25Add rm -v.makepost@firemail.cc
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.
2018-12-04Clean up some --help formatting.Elliott Hughes
Be consistent about upper versus lower case. (Upper seems to have the majority, so I went with that, though I'm happy to provide the opposite patch as long as we're consistent!) Be consistent about using \t. (Though saving a few bytes seems like it might be better done in the code that generates help.h rather than directly in the source, since tabs make careful ASCII art layout hard enough that we regularly have things misaligned.) Remove trailing periods (most of which seem to have been added by me). Always use the US "human readable" rather than my British "human-readable", and be more consistent about declaring whether we're showing multiples of 1000 or 1024. Just say "verbose" rather than adding a useless "mode" or "output".
2016-11-21Have dirtree_notdotdot() pass through !node->parent so . and .. on the commandRob Landley
line aren't filtered out. Audited all the callers and removed redundant calls, adjusted call sequence, etc. (And let rm _not_ do this, because posix.)
2016-01-05Add error_msg_raw() and friends, replace error_msg("%s", s) uses, enable formatRob Landley
checking, and fix up format checking complaints. Added out(type, value) function to stat to avoid a zillion printf typecasts.
2015-09-07Remove prompt argument from yesno(), caller can fprintf(stderr, "blah") itself.Rob Landley
This fixes the build break, the change to yesno() prototype accidentally got checked in last commit. (Oops, sorry.)
2015-02-06In rm, init using to AT_REMOVEDIR in the dir case earlier.Rob Landley
(If you had a chmod 000 directory and did rm -r on it without -f, after the prompt it would complain it was a directory.)
2015-02-06Alright, the Android guys agree with the musl guys: ↵Rob Landley
faccessat(AT_SYMLINK_NOFOLLOW) is not supported.
2014-09-18rm -rf needs to chmod directories to u+rwx, because directories need +x to ↵Isaac Dunham
search. (Fixes messages about not being able to delete directories when running make test).
2014-09-13Bug report from luckboy: rm -f on a broken symlink didn't work because our ↵Rob Landley
"does it exist" test (to avoid errors on rm -f of nonexistent files) said it didn't. The fix: replace the access() with unlink(), which produces the same "does not exist" errno and has the added bonus of acting as a fastpath for rm -f on non-directories. (And since it produces a different error on directories, falls through to the old behavior there.) Most of this commit is comment updates explaining being subtle. :)
2014-07-26Move DIRTREE_COMEAGAIN second callback up to when the filehandle is still ↵Rob Landley
open, and add dir->again variable to distinguish second call instead of checking for -1 filehandle.
2014-07-03Fix rm -rf of chmod 000 directories.Rob Landley
2013-09-06Missing typecast in recent rm fix. Oops.Rob Landley
2013-09-05fix rm to handle "mkdir sub/sub && chmod 007 sub/sub && rm -rf sub".Rob Landley
Previous version didn't delete it, but exited without error. Neither was right.
2013-01-02Have error_msg() and friends set TT.exitval to 1 if it's still 0, clean out ↵Rob Landley
other places that were setting it that no longer need to.
2012-12-12The Linux kernel "make clean" calls rm -f with no arguments, which ↵0.4.2Rob Landley
apparently is not an error.
2012-12-10essat's flag not to follow symlinks isn't in the system call, and if libc is ↵Rob Landley
supposed to implement this as a wrapper uClibc gets it wrong. So use the stat info about symlinks instead. (Doesn't check the parent directory, but if that's read only we can't delete the file anyway so prompting is moot.)
2012-12-08Complicate the rm -i behavior to do what posix specifies.Rob Landley
2012-12-07New rm command.Rob Landley