--- /tmp/f/bin/stow Mon May 22 14:23:07 2000 +++ stow.patched Sun Apr 2 01:35:38 2000 @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl +#!/usr/bin/perl # GNU Stow - manage the installation of multiple software packages # Copyright 1993, 1994, 1995, 1996 by Bob Glickstein @@ -17,6 +17,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# Patched by 1998/07/14 to prevent stow -D / stow -R +# removing initially-empty directories. + $ProgramName = $0; $ProgramName =~ s,.*/,,; @@ -27,7 +30,7 @@ $NotReally = 0; $Verbose = 0; $ReportHelp = 0; -$Stow = &fastcwd; +$Stow = undef; $Target = undef; $Restow = 0; @@ -105,6 +108,11 @@ &usage("No packages named") unless @ARGV; +if ($Stow) { + chdir($Stow) || die "Cannot chdir to target tree $Stow ($!)\n"; +} +$Stow = &fastcwd; + $Target = &parent($Stow) unless $Target; chdir($Target) || die "Cannot chdir to target tree $Target ($!)\n"; @@ -178,6 +186,7 @@ local(@stowmember); local($pure, $othercollection) = (1, ''); local($subpure, $subother); + local($empty) = (1); local(@puresubdirs); return (0, '') if (&JoinPaths($Target, $targetdir) eq $Stow); @@ -190,6 +199,7 @@ closedir(DIR); foreach $content (@contents) { next if (($content eq '.') || ($content eq '..')); + $empty = 0; if (-l &JoinPaths($Target, $targetdir, $content)) { ($linktarget = readlink(&JoinPaths($Target, $targetdir, @@ -240,6 +250,7 @@ $pure = 0; } } + $pure = 0 if $empty; if ((!$pure || !$targetdir) && @puresubdirs) { &CoalesceTrees($targetdir, $stow, @puresubdirs); }