diff options
author | Daniel Dickman <daniel@cvs.openbsd.org> | 2015-10-13 04:30:54 +0000 |
---|---|---|
committer | Daniel Dickman <daniel@cvs.openbsd.org> | 2015-10-13 04:30:54 +0000 |
commit | 307da0b68c33ddfbd603e3616b61dbd0569f34b4 (patch) | |
tree | dcb5256390a84e4ddc51ef88eb6c21e423567cc1 /bin | |
parent | 816fe43bb9232b8f017172af961fe2100773b829 (diff) |
revert previous. changes the behaviour of:
rm -f ""
Diffstat (limited to 'bin')
-rw-r--r-- | bin/rm/rm.1 | 5 | ||||
-rw-r--r-- | bin/rm/rm.c | 34 |
2 files changed, 14 insertions, 25 deletions
diff --git a/bin/rm/rm.1 b/bin/rm/rm.1 index a6a56c825bc..d04e4873272 100644 --- a/bin/rm/rm.1 +++ b/bin/rm/rm.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: rm.1,v 1.38 2015/10/11 03:08:46 daniel Exp $ +.\" $OpenBSD: rm.1,v 1.39 2015/10/13 04:30:53 daniel Exp $ .\" $NetBSD: rm.1,v 1.8 1995/07/25 19:37:30 jtc Exp $ .\" .\" Copyright (c) 1990, 1993, 1994 @@ -33,7 +33,7 @@ .\" .\" @(#)rm.1 8.5 (Berkeley) 12/5/94 .\" -.Dd $Mdocdate: October 11 2015 $ +.Dd $Mdocdate: October 13 2015 $ .Dt RM 1 .Os .Sh NAME @@ -102,7 +102,6 @@ The utility removes symbolic links, not the files referenced by the links. .Pp It is an error to attempt to remove the files -.Dq / , .Dq \&. or .Dq .. . diff --git a/bin/rm/rm.c b/bin/rm/rm.c index e5e339e9dab..7770c6c90d7 100644 --- a/bin/rm/rm.c +++ b/bin/rm/rm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rm.c,v 1.33 2015/10/11 03:08:46 daniel Exp $ */ +/* $OpenBSD: rm.c,v 1.34 2015/10/13 04:30:53 daniel Exp $ */ /* $NetBSD: rm.c,v 1.19 1995/09/07 06:48:50 jtc Exp $ */ /*- @@ -54,7 +54,7 @@ extern char *__progname; int dflag, eval, fflag, iflag, Pflag, stdin_ok; int check(char *, char *, struct stat *); -void checkdotorslash(char **); +void checkdot(char **); void rm_file(char **); int rm_overwrite(char *, struct stat *); int pass(int, off_t, char *, size_t); @@ -113,7 +113,7 @@ main(int argc, char *argv[]) if (argc < 1 && fflag == 0) usage(); - checkdotorslash(argv); + checkdot(argv); if (*argv) { stdin_ok = isatty(STDIN_FILENO); @@ -391,12 +391,12 @@ check(char *path, char *name, struct stat *sp) */ #define ISDOT(a) ((a)[0] == '.' && (!(a)[1] || ((a)[1] == '.' && !(a)[2]))) void -checkdotorslash(char **argv) +checkdot(char **argv) { char *p, **save, **t; - int dotcomplained, slashcomplained; + int complained; - dotcomplained = slashcomplained = 0; + complained = 0; for (t = argv; *t;) { /* strip trailing slashes */ p = strrchr (*t, '\0'); @@ -410,24 +410,14 @@ checkdotorslash(char **argv) p = *t; if (ISDOT(p)) { - if (!dotcomplained) { - dotcomplained = 1; + if (!complained++) warnx("\".\" and \"..\" may not be removed"); - } - } else if (*p == '\0') { - if (!slashcomplained) { - slashcomplained = 1; - warnx("\"/\" may not be removed"); - } - } else { + eval = 1; + for (save = t; (t[0] = t[1]) != NULL; ++t) + continue; + t = save; + } else ++t; - continue; - } - - eval = 1; - for (save = t; (t[0] = t[1]) != NULL; ++t) - continue; - t = save; } } |