Refactor rmdir

Use arg.h- and pointer-iterator-idioms.
This commit is contained in:
FRIGN 2014-06-09 21:03:42 +02:00 committed by sin
parent 612e09af7e
commit 8f7bc0db35

15
rmdir.c
View File

@ -15,15 +15,18 @@ usage(void)
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
argv++;; ARGBEGIN {
if(!*argv) default:
usage();
} ARGEND;
if (argc < 1)
usage(); usage();
while(*argv) { for(; argc > 0; argc--, argv++)
if(rmdir(*argv++) == -1) if(rmdir(argv[0]) == -1)
fprintf(stderr, "rmdir: '%s': %s\n", fprintf(stderr, "rmdir: '%s': %s\n",
argv[-1], strerror(errno)); argv[0], strerror(errno));
}
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }