From: Keith Bostic Date: Tue, 6 Dec 1988 02:31:53 +0000 (-0800) Subject: find . and .. if not at the end of path, i.e. "rm -r /tmp/.*" X-Git-Tag: BSD-4_3_Net_1-Snapshot-Development~195 X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/60b32b72d6486bfc68b5dc04d458aba13e1506d6 find . and .. if not at the end of path, i.e. "rm -r /tmp/.*" SCCS-vsn: bin/rm/rm.c 4.23 --- diff --git a/usr/src/bin/rm/rm.c b/usr/src/bin/rm/rm.c index 13b48ddca3..b26151d78b 100644 --- a/usr/src/bin/rm/rm.c +++ b/usr/src/bin/rm/rm.c @@ -1,4 +1,4 @@ -static char *sccsid = "@(#)rm.c 4.22 (Berkeley) %G%"; +static char *sccsid = "@(#)rm.c 4.23 (Berkeley) %G%"; /* * rm - for ReMoving files, directories & trees. @@ -16,7 +16,7 @@ int rflg; /* -r recurse */ int errcode; /* true if errors occured */ -char *strcpy(), *malloc(); +char *strcpy(); main(argc, argv) int argc; @@ -73,9 +73,14 @@ rm(arg, level) struct direct *dp; /* for reading a directory */ DIR *dirp; /* for reading a directory */ char prevname[MAXNAMLEN + 1]; /* previous name for -r */ - char *cp; - - if (isdot(arg)) { + char *cp, *rindex(); + + cp = rindex(arg, '/'); + if (cp == NULL) + cp = arg; + else + ++cp; + if (isdot(cp)) { fprintf(stderr, "rm: cannot remove `.' or `..'\n"); return (0); } @@ -219,6 +224,7 @@ append(name) char *name; { register int n; + char *malloc(); n = strlen(name); if (path == NULL) {