|
Last change
on this file since 3900 was 2725, checked in by Bruno Cornec, 14 years ago |
- Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | /* vi: set sw=4 ts=4: */
|
|---|
| 2 | /*
|
|---|
| 3 | * Mini rm implementation for busybox
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright (C) 2001 Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
|---|
| 6 | *
|
|---|
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
|---|
| 8 | */
|
|---|
| 9 |
|
|---|
| 10 | /* BB_AUDIT SUSv3 compliant */
|
|---|
| 11 | /* http://www.opengroup.org/onlinepubs/007904975/utilities/rm.html */
|
|---|
| 12 |
|
|---|
| 13 | /* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
|
|---|
| 14 | *
|
|---|
| 15 | * Size reduction.
|
|---|
| 16 | */
|
|---|
| 17 |
|
|---|
| 18 | #include "libbb.h"
|
|---|
| 19 |
|
|---|
| 20 | /* This is a NOFORK applet. Be very careful! */
|
|---|
| 21 |
|
|---|
| 22 | int rm_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
|---|
| 23 | int rm_main(int argc UNUSED_PARAM, char **argv)
|
|---|
| 24 | {
|
|---|
| 25 | int status = 0;
|
|---|
| 26 | int flags = 0;
|
|---|
| 27 | unsigned opt;
|
|---|
| 28 |
|
|---|
| 29 | opt_complementary = "f-i:i-f";
|
|---|
| 30 | /* -v (verbose) is ignored */
|
|---|
| 31 | opt = getopt32(argv, "fiRrv");
|
|---|
| 32 | argv += optind;
|
|---|
| 33 | if (opt & 1)
|
|---|
| 34 | flags |= FILEUTILS_FORCE;
|
|---|
| 35 | if (opt & 2)
|
|---|
| 36 | flags |= FILEUTILS_INTERACTIVE;
|
|---|
| 37 | if (opt & (8|4))
|
|---|
| 38 | flags |= FILEUTILS_RECUR;
|
|---|
| 39 |
|
|---|
| 40 | if (*argv != NULL) {
|
|---|
| 41 | do {
|
|---|
| 42 | const char *base = bb_get_last_path_component_strip(*argv);
|
|---|
| 43 |
|
|---|
| 44 | if (DOT_OR_DOTDOT(base)) {
|
|---|
| 45 | bb_error_msg("can't remove '.' or '..'");
|
|---|
| 46 | } else if (remove_file(*argv, flags) >= 0) {
|
|---|
| 47 | continue;
|
|---|
| 48 | }
|
|---|
| 49 | status = 1;
|
|---|
| 50 | } while (*++argv);
|
|---|
| 51 | } else if (!(flags & FILEUTILS_FORCE)) {
|
|---|
| 52 | bb_show_usage();
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | return status;
|
|---|
| 56 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.