include TZ
[hband-tools.git] / compiled-tools / remove.c
blob9d601b9845737ba55276e4fe3a3e5447426285eb
2 #include <errno.h>
3 #include <err.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <libintl.h>
7 #include <locale.h>
8 #include <stdbool.h>
10 static const char* helptext = "Usage: remove [-v] <PATH> [<PATH> [...]]\n"
11 "Remove files and directories alike.\n";
13 int main(int argc, char** argv)
15 int fail;
16 int idx = 0;
17 bool verbose = false;
19 setlocale(LC_ALL, "");
21 if(argc == 2 && strcmp(argv[1], "--help")==0)
23 printf(helptext);
24 return 0;
27 if(argc >= 2 && (strcmp(argv[1], "-v")==0 || strcmp(argv[1], "--verbose")==0))
29 idx++;
30 verbose = true;
33 if(argc < 2)
35 fprintf(stderr, helptext);
36 return 1;
39 while(argv[++idx] != NULL)
41 fail = remove(argv[idx]);
42 if(fail != 0) err(errno, "%s", argv[idx]);
43 if(verbose) warnx(dcgettext("coreutils", "%s: removed", LC_MESSAGES), argv[idx]);