rm.c (646B)
1 /* See LICENSE file for copyright and license details. */ 2 #include "fs.h" 3 #include "util.h" 4 5 static void 6 usage(void) 7 { 8 eprintf("usage: %s [-f] [-Rr] file ...\n", argv0); 9 } 10 11 int 12 main(int argc, char *argv[]) 13 { 14 struct recursor r = { .fn = rm, .hist = NULL, .depth = 0, .maxdepth = 1, 15 .follow = 'P', .flags = 0 }; 16 17 ARGBEGIN { 18 case 'f': 19 r.flags |= SILENT; 20 break; 21 case 'R': 22 case 'r': 23 r.maxdepth = 0; 24 break; 25 default: 26 usage(); 27 } ARGEND 28 29 if (!argc) { 30 if (!(r.flags & SILENT)) 31 usage(); 32 else 33 return 0; 34 } 35 36 for (; *argv; argc--, argv++) 37 recurse(*argv, NULL, &r); 38 39 return rm_status || recurse_status; 40 }