Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • 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:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/coreutils/rmdir.c

    r1765 r2725  
    55 * Copyright (C) 2003  Manuel Novoa III  <mjn3@codepoet.org>
    66 *
    7  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
     7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    88 */
    99
     
    1111/* http://www.opengroup.org/onlinepubs/007904975/utilities/rmdir.html */
    1212
    13 #include <libgen.h>
    1413#include "libbb.h"
    1514
     
    1716
    1817
    19 int rmdir_main(int argc, char **argv);
    20 int rmdir_main(int argc, char **argv)
     18#define PARENTS 0x01
     19#define IGNORE_NON_EMPTY 0x02
     20
     21int rmdir_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
     22int rmdir_main(int argc UNUSED_PARAM, char **argv)
    2123{
    2224    int status = EXIT_SUCCESS;
    2325    int flags;
    24     int do_dot;
    2526    char *path;
    2627
     28#if ENABLE_FEATURE_RMDIR_LONG_OPTIONS
     29    static const char rmdir_longopts[] ALIGN1 =
     30        "parents\0"                  No_argument "p"
     31        /* Debian etch: many packages fail to be purged or installed
     32         * because they desperately want this option: */
     33        "ignore-fail-on-non-empty\0" No_argument "\xff"
     34        ;
     35    applet_long_options = rmdir_longopts;
     36#endif
    2737    flags = getopt32(argv, "p");
    2838    argv += optind;
     
    3545        path = *argv;
    3646
    37         /* Record if the first char was a '.' so we can use dirname later. */
    38         do_dot = (*path == '.');
    39 
    4047        while (1) {
    4148            if (rmdir(path) < 0) {
    42                 bb_perror_msg("'%s'", path);    /* Match gnu rmdir msg. */
     49#if ENABLE_FEATURE_RMDIR_LONG_OPTIONS
     50                if ((flags & IGNORE_NON_EMPTY) && errno == ENOTEMPTY)
     51                    break;
     52#endif
     53                bb_perror_msg("'%s'", path);  /* Match gnu rmdir msg. */
    4354                status = EXIT_FAILURE;
    44             } else if (flags) {
    45                 /* Note: path was not empty or null since rmdir succeeded. */
     55            } else if (flags & PARENTS) {
     56                /* Note: path was not "" since rmdir succeeded. */
    4657                path = dirname(path);
    47                 /* Path is now just the parent component.  Note that dirname
    48                  * returns "." if there are no parents.  We must distinguish
    49                  * this from the case of the original path starting with '.'.
     58                /* Path is now just the parent component.  Dirname
     59                 * returns "." if there are no parents.
    5060                 */
    51                 if (do_dot || (*path != '.') || path[1]) {
     61                if (NOT_LONE_CHAR(path, '.')) {
    5262                    continue;
    5363                }
     
    5565            break;
    5666        }
    57 
    5867    } while (*++argv);
    5968
Note: See TracChangeset for help on using the changeset viewer.