Subject: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so.

From: Eric Blake <[email-masked]>
Date: Fri, 07 Sep 2012 18:01:21 -0600

On 09/07/2012 09:02 AM, Linda Walsh wrote:

> 
> --- src/remove.c        2011-10-10 00:56:46.000000000 -0700
> +++ src/remove.c.new    2012-09-06 14:28:07.816810683 -0700

Thanks for making an attempt to show what you want in code.  However,
you provided no ChangeLog entry, no mention in NEWS and no
documentation.  Also, you do not have copyright assignment on file with
the FSF (but if you'd like to pursue this patch further, we can help you
complete the copyright assignment paperwork).  Therefore, this patch
cannot be taken as-is.

> @@ -203,6 +232,7 @@
> 
>    int dirent_type = is_dir ? DT_DIR : DT_UNKNOWN;
>    int write_protected = 0;
> +       int special_delete_content = 0;

Furthermore, your indentation appears hideous in this email; I'm not
sure you created the patch, and whether this is an artifact of your
mailer corrupting things or whether you really did disregard existing
indentation, but you'd have to clean that up before your patch can be
anywhere worth including.

> +                                       char * action =
> special_delete_content
> +                                                                             
> ? _("delete contents of")
> +                                                                             
> : _("descend into");
> +                                       fprintf (stderr,
> + (write_protected
> +                                                                             
> ? _("%s: %s write-protected directory %s? ")
> +                                                                             
> : _("%s: %s directory %s? ")),

This is a translation no-no (not to mention that your hideous
indentation made it hard to read because it was so much longer than 80
columns).  Please don't split English sentences across two separate _()
calls that are then pasted together, but rather write two _() calls of
the two complete sentences.

> +++ src/rm.c    2012-09-06 13:33:04.132500554 -0700
> @@ -206,6 +206,7 @@
>    bool preserve_root = true;
>    struct rm_options x;
>    bool prompt_once = false;
> +       x.posix_correctly = (getenv ("POSIXLY_CORRECT") != NULL );

Elsewhere in coreutils, we name such a variable posixly_correct, not
posix_correctly.

And finally, remember my advice - if you want this mode, add it as a new
long option, and NOT as an abuse of POSIXLY_CORRECT, if you want to
avoid controversy and even stand a chance of getting it approved for
inclusion.

-- 
Eric Blake   [email-masked]    +1-919-301-3266
Libvirt virtualization library http://libvirt.org