Re: bin/rmdir -p option bug [patch]

看板DFBSD_submit作者時間21年前 (2004/09/12 20:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
--VS++wcV0S1rZb1Fb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jul 22, 2004 at 08:39:44PM +0200, Douwe Kiela wrote: > Hey peeps, > > According to SUSv3, the -p option should behave exactly the same as rmdir > without any option, only that it recursively removes all directories > mentioned > as arguments in the command line. In the current rmdir, you can't remove > multiple directories and meanwhile recursively remove all it's > subdirectories. It still doesn't work as expected. What do you think of the attached patch? Joerg --VS++wcV0S1rZb1Fb Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="rmdir.c.diff" Index: Makefile =================================================================== RCS file: /home/joerg/wd/repository/dragonflybsd/src/bin/rmdir/Makefile,v retrieving revision 1.2 diff -u -r1.2 Makefile --- Makefile 17 Jun 2003 04:22:50 -0000 1.2 +++ Makefile 8 Sep 2004 14:57:32 -0000 @@ -4,6 +4,6 @@ PROG= rmdir -WARNS?= 2 +WARNS?= 6 .include <bsd.prog.mk> Index: rmdir.c =================================================================== RCS file: /home/joerg/wd/repository/dragonflybsd/src/bin/rmdir/rmdir.c,v retrieving revision 1.5 diff -u -r1.5 rmdir.c --- rmdir.c 24 Jul 2004 10:47:10 -0000 1.5 +++ rmdir.c 8 Sep 2004 14:58:13 -0000 @@ -69,11 +69,12 @@ usage(); for (errors = 0; *argv; argv++) { - if (rmdir(*argv) < 0) { + if (pflag) { + errors |= rm_path(*argv); + } else if (rmdir(*argv) < 0) { warn("%s", *argv); errors = 1; - } else if (pflag) - errors |= rm_path(*argv); + } } exit(errors); @@ -85,10 +86,7 @@ char *p; p = path + strlen(path); - while (--p > path && *p == '/') - ; - *++p = '\0'; - while ((p = strrchr(path, '/')) != NULL) { + do { /* Delete trailing slashes. */ while (--p > path && *p == '/') ; @@ -99,6 +97,7 @@ return (1); } } + while ((p = strrchr(path, '/')) != NULL); return (0); } --VS++wcV0S1rZb1Fb--
文章代碼(AID): #11H3g700 (DFBSD_submit)
文章代碼(AID): #11H3g700 (DFBSD_submit)