Hi
The attached patch takes care of the following situation:
mkdir foo
touch foo/bar (optional)
chmod 0 foo
rm -rf foo
not working as it can't chdir to foo.
I need this as my backup scripts back up directories like this (out of
necessity, they're part of a test-suite) but they then don't get
rotated as rm -rf fails on the oldest backup.
Thanks
Ian
diff -ur fileutils-4.0.37/ChangeLog fileutils-4.0.37-igl/ChangeLog
--- fileutils-4.0.37/ChangeLog Sun Jan 21 12:27:38 2001
+++ fileutils-4.0.37-igl/ChangeLog Mon Feb 5 22:47:58 2001
@@ -1,3 +1,8 @@
+2001-02-05 Ian Lynagh <[EMAIL PROTECTED]>
+
+ * chmod directories u+rwx if necessary first if interactive is 0
+ so we can remove them
+
2001-01-21 Jim Meyering <[EMAIL PROTECTED]>
* Version 4.0.37.
diff -ur fileutils-4.0.37/THANKS fileutils-4.0.37-igl/THANKS
--- fileutils-4.0.37/THANKS Sat Jan 13 15:48:59 2001
+++ fileutils-4.0.37-igl/THANKS Mon Feb 5 23:01:02 2001
@@ -119,6 +119,7 @@
Hugh Daniel [EMAIL PROTECTED]
Ian Jackson [EMAIL PROTECTED]
Ian Lance Taylor [EMAIL PROTECTED]
+Ian Lynagh [EMAIL PROTECTED]
Ian Turner [EMAIL PROTECTED]
James [EMAIL PROTECTED]
James Antill [EMAIL PROTECTED]
--- fileutils-4.0.37/src/remove.c Mon Dec 25 10:44:42 2000
+++ fileutils-4.0.37-igl/src/remove.c Mon Feb 5 22:47:00 2001
@@ -702,6 +702,12 @@
if (need_save_cwd && save_cwd (&cwd))
return RM_ERROR;
+ /* Make target directory u+rwx if it isn't already */
+ if ((!(fs->mode & S_IRUSR) || !(fs->mode & S_IWUSR) || !(fs->mode & S_IXUSR))
+ && !x->interactive)
+ /* We don't care about errors here, let them get caught below */
+ chmod (dir_name, fs->mode | S_IRUSR | S_IWUSR | S_IXUSR);
+
/* Make target directory the current one. */
if (chdir (dir_name) < 0)
{