2011-05-23 20:52:28 -04:00
|
|
|
/* See LICENSE file for copyright and license details. */
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
2012-01-30 17:41:33 -05:00
|
|
|
#include <sys/stat.h>
|
2014-11-13 12:29:30 -05:00
|
|
|
|
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)
|
|
|
|
{
|
2015-01-30 05:34:05 -05:00
|
|
|
eprintf("usage: %s [-f | -i] [-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[])
|
|
|
|
{
|
2013-06-14 14:20:47 -04:00
|
|
|
ARGBEGIN {
|
|
|
|
case 'f':
|
2014-11-13 15:24:47 -05:00
|
|
|
rm_fflag = 1;
|
2013-06-14 14:20:47 -04:00
|
|
|
break;
|
2015-01-30 05:34:05 -05:00
|
|
|
case 'i':
|
|
|
|
rm_fflag = 0;
|
|
|
|
break;
|
2013-12-12 08:15:07 -05:00
|
|
|
case 'R':
|
2013-06-14 14:20:47 -04:00
|
|
|
case 'r':
|
2014-11-13 15:24:47 -05:00
|
|
|
rm_rflag = 1;
|
2013-06-14 14:20:47 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
usage();
|
|
|
|
} ARGEND;
|
2013-08-31 18:04:49 -04:00
|
|
|
|
2014-07-04 09:50:20 -04:00
|
|
|
if (argc < 1) {
|
2014-11-13 15:24:47 -05:00
|
|
|
if (!rm_fflag)
|
2014-07-04 09:50:20 -04:00
|
|
|
usage();
|
|
|
|
else
|
2014-10-02 18:46:04 -04:00
|
|
|
return 0;
|
2014-07-04 09:50:20 -04:00
|
|
|
}
|
2013-08-31 18:04:49 -04:00
|
|
|
|
2014-11-13 12:29:30 -05:00
|
|
|
for (; argc > 0; argc--, argv++)
|
2013-06-14 14:20:47 -04:00
|
|
|
rm(argv[0]);
|
2011-05-23 20:52:28 -04:00
|
|
|
|
2015-01-30 06:45:54 -05:00
|
|
|
return rm_status;
|
2011-05-23 20:52:28 -04:00
|
|
|
}
|