sbase/rm.c

42 lines
615 B
C
Raw Normal View History

2011-05-24 00:52:28 +00:00
/* See LICENSE file for copyright and license details. */
#include <fcntl.h>
2012-01-30 22:41:33 +00:00
#include "fs.h"
2011-05-24 00:52:28 +00:00
#include "util.h"
2013-06-14 18:20:47 +00:00
static void
usage(void)
{
eprintf("usage: %s [-f] [-Rr] file ...\n", argv0);
2013-06-14 18:20:47 +00:00
}
2011-05-24 00:52:28 +00:00
int
main(int argc, char *argv[])
{
struct recursor r = { .fn = rm, .maxdepth = 1, .follow = 'P' };
2013-06-14 18:20:47 +00:00
ARGBEGIN {
case 'f':
r.flags |= SILENT;
2013-06-14 18:20:47 +00:00
break;
case 'R':
2013-06-14 18:20:47 +00:00
case 'r':
r.maxdepth = 0;
2013-06-14 18:20:47 +00:00
break;
default:
usage();
} ARGEND
if (!argc) {
if (!(r.flags & SILENT))
usage();
else
2014-10-02 22:46:04 +00:00
return 0;
}
for (; *argv; argc--, argv++)
recurse(AT_FDCWD, *argv, NULL, &r);
2011-05-24 00:52:28 +00:00
return rm_status || recurse_status;
2011-05-24 00:52:28 +00:00
}