sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit 8f7bc0db354a20061a409fc72bb1e6d2ff47fff3
parent 612e09af7e9ff1ffca64652b6561871aec3db5de
Author: FRIGN <dev@frign.de>
Date:   Mon,  9 Jun 2014 21:03:42 +0200

Refactor rmdir

Use arg.h- and pointer-iterator-idioms.

Diffstat:
Mrmdir.c | 15+++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)

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