rmdir.c revision 1556
1105068Sphk/*-
2105068Sphk * Copyright (c) 1992, 1993, 1994
3105068Sphk *	The Regents of the University of California.  All rights reserved.
4105068Sphk *
5105068Sphk * Redistribution and use in source and binary forms, with or without
6105068Sphk * modification, are permitted provided that the following conditions
7105068Sphk * are met:
8105068Sphk * 1. Redistributions of source code must retain the above copyright
9105068Sphk *    notice, this list of conditions and the following disclaimer.
10105068Sphk * 2. Redistributions in binary form must reproduce the above copyright
11105068Sphk *    notice, this list of conditions and the following disclaimer in the
12105068Sphk *    documentation and/or other materials provided with the distribution.
13105068Sphk * 3. All advertising materials mentioning features or use of this software
14105068Sphk *    must display the following acknowledgement:
15105068Sphk *	This product includes software developed by the University of
16105068Sphk *	California, Berkeley and its contributors.
17105068Sphk * 4. Neither the name of the University nor the names of its contributors
18105068Sphk *    may be used to endorse or promote products derived from this software
19105068Sphk *    without specific prior written permission.
20105068Sphk *
21105068Sphk * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22105068Sphk * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23105068Sphk * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24105068Sphk * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25105068Sphk * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26105068Sphk * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27105068Sphk * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28105068Sphk * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29105068Sphk * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30105068Sphk * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31105068Sphk * SUCH DAMAGE.
32105068Sphk */
33105068Sphk
34105068Sphk#ifndef lint
35105068Sphkstatic char copyright[] =
36116196Sobrien"@(#) Copyright (c) 1992, 1993, 1994\n\
37116196Sobrien	The Regents of the University of California.  All rights reserved.\n";
38116196Sobrien#endif /* not lint */
39105068Sphk
40105068Sphk#ifndef lint
41105068Sphkstatic char sccsid[] = "@(#)rmdir.c	8.3 (Berkeley) 4/2/94";
42105068Sphk#endif /* not lint */
43105068Sphk
44105068Sphk#include <err.h>
45105068Sphk#include <errno.h>
46105068Sphk#include <stdio.h>
47105068Sphk#include <stdlib.h>
48105068Sphk#include <string.h>
49105068Sphk#include <unistd.h>
50113892Sphk
51105068Sphkvoid usage __P((void));
52105068Sphk
53105068Sphkint
54112511Sphkmain(argc, argv)
55112511Sphk	int argc;
56112511Sphk	char *argv[];
57112511Sphk{
58105068Sphk	int ch, errors;
59105068Sphk
60112709Sphk	while ((ch = getopt(argc, argv, "")) != EOF)
61112511Sphk		switch(ch) {
62105068Sphk		case '?':
63113892Sphk		default:
64113892Sphk			usage();
65105068Sphk		}
66105068Sphk	argc -= optind;
67112534Sphk	argv += optind;
68126080Sphk
69126080Sphk	if (argc == 0)
70112534Sphk		usage();
71112534Sphk
72105068Sphk	for (errors = 0; *argv; ++argv)
73105068Sphk		if (rmdir(*argv) < 0) {
74112534Sphk			warn("%s", *argv);
75105068Sphk			errors = 1;
76105068Sphk		}
77105068Sphk	exit(errors);
78112534Sphk}
79112534Sphk
80112709Sphkvoid
81112709Sphkusage()
82112709Sphk{
83112709Sphk
84105068Sphk	(void)fprintf(stderr, "usage: rmdir directory ...\n");
85105068Sphk	exit(1);
86112511Sphk}
87112511Sphk