sbase/rm.c

40 lines
586 B
C
Raw Normal View History

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