| Line | |
|---|
| 1 | /* rmdir - remove directory */
|
|---|
| 2 |
|
|---|
| 3 | /* See Makefile for compilation details. */
|
|---|
| 4 |
|
|---|
| 5 | #include "config.h"
|
|---|
| 6 |
|
|---|
| 7 | #include <stdio.h>
|
|---|
| 8 | #include <errno.h>
|
|---|
| 9 | #include "builtins.h"
|
|---|
| 10 | #include "shell.h"
|
|---|
| 11 |
|
|---|
| 12 | #if !defined (errno)
|
|---|
| 13 | extern int errno;
|
|---|
| 14 | #endif
|
|---|
| 15 |
|
|---|
| 16 | rmdir_builtin (list)
|
|---|
| 17 | WORD_LIST *list;
|
|---|
| 18 | {
|
|---|
| 19 | int rval;
|
|---|
| 20 | WORD_LIST *l;
|
|---|
| 21 |
|
|---|
| 22 | if (no_options (list))
|
|---|
| 23 | return (EX_USAGE);
|
|---|
| 24 |
|
|---|
| 25 | for (rval = EXECUTION_SUCCESS, l = list; l; l = l->next)
|
|---|
| 26 | if (rmdir (l->word->word) < 0)
|
|---|
| 27 | {
|
|---|
| 28 | builtin_error ("%s: %s", l->word->word, strerror (errno));
|
|---|
| 29 | rval = EXECUTION_FAILURE;
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | return rval;
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | char *rmdir_doc[] = {
|
|---|
| 36 | "rmdir removes the directory entry specified by each argument,",
|
|---|
| 37 | "provided the directory is empty.",
|
|---|
| 38 | (char *)NULL
|
|---|
| 39 | };
|
|---|
| 40 |
|
|---|
| 41 | /* The standard structure describing a builtin command. bash keeps an array
|
|---|
| 42 | of these structures. */
|
|---|
| 43 | struct builtin rmdir_struct = {
|
|---|
| 44 | "rmdir", /* builtin name */
|
|---|
| 45 | rmdir_builtin, /* function implementing the builtin */
|
|---|
| 46 | BUILTIN_ENABLED, /* initial flags for builtin */
|
|---|
| 47 | rmdir_doc, /* array of long documentation strings. */
|
|---|
| 48 | "rmdir directory ...", /* usage synopsis; becomes short_doc */
|
|---|
| 49 | 0 /* reserved for internal use */
|
|---|
| 50 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.