1 /* vi: set sw=4 ts=4: */
3 * rmdir implementation for busybox
5 * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
10 /* BB_AUDIT SUSv3 compliant */
11 /* http://www.opengroup.org/onlinepubs/007904975/utilities/rmdir.html */
16 /* This is a NOFORK applet. Be very careful! */
19 int rmdir_main(int argc, char **argv);
20 int rmdir_main(int argc, char **argv)
22 int status = EXIT_SUCCESS;
27 flags = getopt32(argv, "p");
37 /* Record if the first char was a '.' so we can use dirname later. */
38 do_dot = (*path == '.');
41 if (rmdir(path) < 0) {
42 bb_perror_msg("'%s'", path); /* Match gnu rmdir msg. */
43 status = EXIT_FAILURE;
45 /* Note: path was not empty or null since rmdir succeeded. */
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 '.'.
51 if (do_dot || (*path != '.') || path[1]) {