bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FYI, 11 mostly-test-related patches


From: Bo Borgerson
Subject: Re: FYI, 11 mostly-test-related patches
Date: Mon, 28 Apr 2008 13:25:03 -0400
User-agent: Thunderbird 2.0.0.12 (X11/20080227)

Jim Meyering wrote:
> "Bo Borgerson" <address@hidden> wrote:
>> I think File::Temp does this internally as well, but it looks like
>> chmod_tree will just warn about the failed chdir and procede to
>> recursively chmod whatever directory it was in at the time if $dir is
>> yanked out from under it.
> 
> Yes.  Good catch.  It should obviously skip the find in that case.
> Want to write the patch?


Sure, I think this should do it.

Thanks,

Bo
>From 769e662c3643c0b3dc21e96dec2e2f1cd481fb70 Mon Sep 17 00:00:00 2001
From: Bo Borgerson <address@hidden>
Date: Mon, 28 Apr 2008 13:11:26 -0400
Subject: [PATCH] tests: don't chmod after a failed chdir in cleanup

* tests/CuTmpdir.pm (chmod_tree): Don't chmod if chdir failed.

Signed-off-by: Bo Borgerson <address@hidden>
---
 tests/CuTmpdir.pm |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/tests/CuTmpdir.pm b/tests/CuTmpdir.pm
index 84312a0..e21306a 100644
--- a/tests/CuTmpdir.pm
+++ b/tests/CuTmpdir.pm
@@ -45,11 +45,16 @@ sub chmod_1
 
 sub chmod_tree
 {
-  chdir $dir
-    or warn "$ME: failed to chdir to $dir: $!\n";
-  # Perform the equivalent of find . -type d -print0|xargs -0 chmod -R 700.
-  my $options = {untaint => 1, wanted => \&chmod_1};
-  find ($options, '.');
+  if (chdir $dir)
+    {
+      # Perform the equivalent of find . -type d -print0|xargs -0 chmod -R 700.
+      my $options = {untaint => 1, wanted => \&chmod_1};
+      find ($options, '.');
+    }
+  else
+    {
+      warn "$ME: failed to chdir to $dir: $!\n";
+    }
 }
 
 sub import {
-- 
1.5.4.3


reply via email to

[Prev in Thread] Current Thread [Next in Thread]