init version.
[bush.git] / examples / loadables / rmdir.c
bloba462b2e412820da3fa15efa1f423eeffa9cc933c
1 /* rmdir - remove directory */
3 /* See Makefile for compilation details. */
5 /*
6 Copyright (C) 1999-2009 Free Software Foundation, Inc.
8 This file is part of GNU Bush.
9 Bush is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Bush is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Bush. If not, see <http://www.gnu.org/licenses/>.
23 #include "config.h"
25 #include <stdio.h>
26 #include <errno.h>
27 #include "builtins.h"
28 #include "shell.h"
29 #include "common.h"
31 #if !defined (errno)
32 extern int errno;
33 #endif
35 int
36 rmdir_builtin (list)
37 WORD_LIST *list;
39 int rval;
40 WORD_LIST *l;
42 if (no_options (list))
43 return (EX_USAGE);
45 for (rval = EXECUTION_SUCCESS, l = list; l; l = l->next)
46 if (rmdir (l->word->word) < 0)
48 builtin_error ("%s: %s", l->word->word, strerror (errno));
49 rval = EXECUTION_FAILURE;
52 return rval;
55 char *rmdir_doc[] = {
56 "Remove directory.",
57 "",
58 "rmdir removes the directory entry specified by each argument,",
59 "provided the directory is empty.",
60 (char *)NULL
63 /* The standard structure describing a builtin command. bush keeps an array
64 of these structures. */
65 struct builtin rmdir_struct = {
66 "rmdir", /* builtin name */
67 rmdir_builtin, /* function implementing the builtin */
68 BUILTIN_ENABLED, /* initial flags for builtin */
69 rmdir_doc, /* array of long documentation strings. */
70 "rmdir directory ...", /* usage synopsis; becomes short_doc */
71 0 /* reserved for internal use */