From 63fb6398455347084df0a39dd488bb94f84a96e9 Mon Sep 17 00:00:00 2001 From: Guillaume Rousse Date: Thu, 8 May 2008 16:43:58 +0000 Subject: no more usage of external find command --- compress_files | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'compress_files') diff --git a/compress_files b/compress_files index 9dcbddc..d95000e 100755 --- a/compress_files +++ b/compress_files @@ -145,22 +145,22 @@ foreach (keys %hardlinks) { } # Fix up symlinks that were pointing to the uncompressed files. -my $FIND; -open($FIND, "find $buildroot -type l |"); -while (<$FIND>) { - local $_ = $_; - chomp; - my ($directory) = m!(.*)/!; +my $link_function = sub { + # skip everything but symlinks + return unless -l $_; + # skip non-dangling symlinks my $linkval = readlink($_); - if (! -e "$directory/$linkval" && -e "$directory/$linkval$ext") { + return if -e "$File::Find::dir/$linkval"; + + if (-e "$File::Find::dir/$linkval$ext") { unlink $_; symlink "$linkval$ext", "$_$ext"; - } elsif (! -e "$directory/$linkval" && ! -e "$directory/$linkval$ext" && $directory =~ m|man/|) { - #Bad link go on nowhere (any better idea) ? + } elsif ($File::Find::dir =~ m|man/|) { + # Bad link go on nowhere (any better idea) ? unlink $_; } - -} +}; +find($link_function, $buildroot); # Run a command that may have a huge number of arguments, like xargs does. # Pass in a reference to an array containing the arguments, and then other -- cgit v1.2.1