Theo Buehler wrote:
> In episode 103 of BSD Now, Bryan Cantrill talks about the fact that
> on illumos "rm -rf /" is an error. It turns out that this behavior
> is mandated by POSIX 1003.1-2013:
>
> "If either of the files dot or dot-dot are specified as the basename
> portion of an operand (that is, the final pathname component) or if an
> operand resolves to the root directory, rm shall write a diagnostic
> message to standard error and do nothing more with such operands."
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/rm.html
>
> On FreeBSD, a check for "/" only happens if POSIXLY_CORRECT is set,
> while on NetBSD, there currently is no such check at all.
> @@ -401,9 +401,10 @@ checkdot(char **argv)
> else
> p = *t;
>
> - if (ISDOT(p)) {
> + if (ISDOT(p) || *p == '\0') {
> if (!complained++)
> - warnx("\".\" and \"..\" may not be removed");
> + warnx("\"/\", \".\" and \"..\" may not be "
> + "removed");
> eval = 1;
> for (save = t; (t[0] = t[1]) != NULL; ++t)
> continue;
>
I think separate error messages are appriate. The one about dots should not be
cluttered with this.