morpheus-base

morpheus base system
git clone git://git.2f30.org/morpheus-base
Log | Files | Refs

rm.c (547B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include <stdio.h>
      3 #include <stdlib.h>
      4 #include <unistd.h>
      5 #include <sys/stat.h>
      6 
      7 #include "fs.h"
      8 #include "util.h"
      9 
     10 static void
     11 usage(void)
     12 {
     13 	eprintf("usage: %s [-fRr] FILE...\n", argv0);
     14 }
     15 
     16 int
     17 main(int argc, char *argv[])
     18 {
     19 	ARGBEGIN {
     20 	case 'f':
     21 		rm_fflag = 1;
     22 		break;
     23 	case 'R':
     24 	case 'r':
     25 		rm_rflag = 1;
     26 		break;
     27 	default:
     28 		usage();
     29 	} ARGEND;
     30 
     31 	if (argc < 1) {
     32 		if (!rm_fflag)
     33 			usage();
     34 		else
     35 			return 0;
     36 	}
     37 
     38 	for (; argc > 0; argc--, argv++)
     39 		rm(argv[0]);
     40 
     41 	return 0;
     42 }