committed with a minor tweak Thanks!

>
> Do I miss something simpler?
>
> Index: bin/rm/rm.1
> ===================================================================
> RCS file: /var/cvs/src/bin/rm/rm.1,v
> retrieving revision 1.37
> diff -u -p -r1.37 rm.1
> --- bin/rm/rm.1 25 May 2014 19:07:36 -0000      1.37
> +++ bin/rm/rm.1 22 Aug 2015 21:49:02 -0000
> @@ -102,6 +102,7 @@ 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 .. .
> Index: bin/rm/rm.c
> ===================================================================
> RCS file: /var/cvs/src/bin/rm/rm.c,v
> retrieving revision 1.30
> diff -u -p -r1.30 rm.c
> --- bin/rm/rm.c 16 Jan 2015 06:39:32 -0000      1.30
> +++ bin/rm/rm.c 23 Aug 2015 11:52:28 -0000
> @@ -54,7 +54,7 @@ extern char *__progname;
>  int dflag, eval, fflag, iflag, Pflag, stdin_ok;
>
>  int    check(char *, char *, struct stat *);
> -void   checkdot(char **);
> +void   checkdotorslash(char **);
>  void   rm_file(char **);
>  int    rm_overwrite(char *, struct stat *);
>  int    pass(int, off_t, char *, size_t);
> @@ -105,7 +105,7 @@ main(int argc, char *argv[])
>         if (argc < 1 && fflag == 0)
>                 usage();
>
> -       checkdot(argv);
> +       checkdotorslash(argv);
>
>         if (*argv) {
>                 stdin_ok = isatty(STDIN_FILENO);
> @@ -383,12 +383,12 @@ check(char *path, char *name, struct sta
>   */
>  #define ISDOT(a)       ((a)[0] == '.' && (!(a)[1] || ((a)[1] == '.' && 
> !(a)[2])))
>  void
> -checkdot(char **argv)
> +checkdotorslash(char **argv)
>  {
>         char *p, **save, **t;
> -       int complained;
> +       int dotcomplained, slashcomplained;
>
> -       complained = 0;
> +       dotcomplained = slashcomplained = 0;
>         for (t = argv; *t;) {
>                 /* strip trailing slashes */
>                 p = strrchr (*t, '\0');
> @@ -402,14 +402,20 @@ checkdot(char **argv)
>                         p = *t;
>
>                 if (ISDOT(p)) {
> -                       if (!complained++)
> +                       if (!dotcomplained++)
>                                 warnx("\".\" and \"..\" may not be removed");
> -                       eval = 1;
> -                       for (save = t; (t[0] = t[1]) != NULL; ++t)
> -                               continue;
> -                       t = save;
> -               } else
> +               } else if (*p == '\0') {
> +                       if (!slashcomplained++)
> +                               warnx("\"/\" may not be removed");
> +               } else {
>                         ++t;
> +                       continue;
> +               }
> +
> +               eval = 1;
> +               for (save = t; (t[0] = t[1]) != NULL; ++t)
> +                       continue;
> +               t = save;
>         }
>  }
>
>

Reply via email to