]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: CuTmpdir.pm: avoid use of undefined variable in warning
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Wed, 25 Mar 2009 09:15:46 +0000 (10:15 +0100)
committerJim Meyering <meyering@redhat.com>
Wed, 25 Mar 2009 09:16:34 +0000 (10:16 +0100)
* tests/CuTmpdir.pm (chmod_tree): Do not warn if $dir is undefined.

tests/CuTmpdir.pm

index 166e50bd83a3f52b0cc362b7a385123aa46b670c..1e52640862976ff48386bf88d1819dc5d717b6d1 100644 (file)
@@ -1,7 +1,7 @@
 package CuTmpdir;
 # create, then chdir into a temporary sub-directory
 
-# Copyright (C) 2007-2008 Free Software Foundation, Inc.
+# Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -45,7 +45,11 @@ sub chmod_1
 
 sub chmod_tree
 {
-  if (defined $dir && chdir $dir)
+  # When tempdir fails, it croaks, which leaves $dir undefined.
+  defined $dir
+    or return;
+
+  if (chdir $dir)
     {
       # Perform the equivalent of find . -type d -print0|xargs -0 chmod -R 700.
       my $options = {untaint => 1, wanted => \&chmod_1};