Mercurial > hg > toybox
diff toys/posix/rmdir.c @ 782:3d7526f6115b
Use basename() where appropriate.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 05 Jan 2013 00:44:24 -0600 |
parents | 786841fdb1e0 |
children | fc1bb49e58a9 |
line wrap: on
line diff
--- a/toys/posix/rmdir.c Fri Jan 04 21:10:49 2013 -0600 +++ b/toys/posix/rmdir.c Sat Jan 05 00:44:24 2013 -0600 @@ -20,16 +20,21 @@ static void do_rmdir(char *name) { + char *temp; + for (;;) { - char *temp; - if (rmdir(name)) { perror_msg("%s",name); return; } + + // Each -p cycle back up one slash, ignoring trailing and repeated /. + if (!toys.optflags) return; - if (!(temp=strrchr(name,'/'))) return; - *temp=0; + do { + if (!(temp = strrchr(name, '/'))) return; + *temp = 0; + } while (!temp[1]); } }