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 */
18 int rmdir_main(int argc, char **argv)
20 int status = EXIT_SUCCESS;
25 flags = getopt32(argc, argv, "p");
36 /* Record if the first char was a '.' so we can use dirname later. */
37 do_dot = (*path == '.');
40 if (rmdir(path) < 0) {
41 bb_perror_msg("'%s'", path); /* Match gnu rmdir msg. */
42 status = EXIT_FAILURE;
44 /* Note: path was not empty or null since rmdir succeeded. */
46 /* Path is now just the parent component. Note that dirname
47 * returns "." if there are no parents. We must distinguish
48 * this from the case of the original path starting with '.'.
50 if (do_dot || (*path != '.') || path[1]) {