Don't strip trailing slashes (for the initial rmdir). It breaks
following of the symlink for `rmdir symlink/' and is unnecessary for ordinary directories (POSIX doesn't require rmdir(1) to do anything for trailing slashes; it requires rmdir(2) to let them "refer to a directory", and following the symlink for symlink/ is what BSD does). This also fixes bugs in the slash-stripping code (for paths consisting entirely of slashes, the pointer into the string was decremented to "before" the beginning of the string, and the path was at best stripped to "". The behaviour is unchanged except for the final directory for `rmdir -p ...'. There is no alternative to stripping intermediate slashes since they must be specified. The sloppy slash-stripping code is adequate for intermediate directories, since the all-slashes case fails early.
This commit is contained in:
parent
ae9996d766
commit
d102d16ab7
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: rmdir.c,v 1.5 1997/02/22 14:05:40 peter Exp $
|
||||
* $Id: rmdir.c,v 1.6 1997/03/28 15:24:37 imp Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -78,14 +78,6 @@ main(argc, argv)
|
||||
usage();
|
||||
|
||||
for (errors = 0; *argv; argv++) {
|
||||
char *p;
|
||||
|
||||
/* Delete trailing slashes, per POSIX. */
|
||||
p = *argv + strlen(*argv);
|
||||
while (--p > *argv && *p == '/')
|
||||
;
|
||||
*++p = '\0';
|
||||
|
||||
if (rmdir(*argv) < 0) {
|
||||
warn("%s", *argv);
|
||||
errors = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user