5 @LINKS=`find . -type l|xargs ls -l`;
10 while($_ = shift @LINKS){
12 my ($perm,$nlinks,$owner,$group,$size,$month,$day,$year,$file) =
17 ($relfile, $link) = split(' -> ', $file);
20 # chop off leading . in $file
25 my @pathcomponents = split('/', $file);
26 my @linkcomponents = split('/', $link);
29 @newcomponents = @linkcomponents;
31 @newcomponents = @pathcomponents;
36 while($comp = shift @linkcomponents){
37 #print "path: ",join(':',@newcomponents)," -- $comp -- ", join(':',@linkcomponents),"\n";
41 }elsif($comp eq ".."){
44 push @newcomponents,$comp;
49 if($newcomponents[0] eq ""){
50 shift(@newcomponents);
52 if($pathcomponents[0] eq ""){
53 shift(@pathcomponents);
56 #print "from ",join('/',@pathcomponents),"\n";
57 #print "to ",join('/',@newcomponents),"\n";
59 if($newcomponents[0] eq $pathcomponents[0]){
60 #print $newcomponents[0],", ",$pathcomponents[0];
61 #print "should be relative\n";
62 while($newcomponents[0] eq $pathcomponents[0]){
63 shift(@newcomponents);
64 shift(@pathcomponents);
66 while(@pathcomponents > 1){
67 shift(@pathcomponents);
68 unshift(@newcomponents,"..");
71 #print "should be absolute\n";
72 unshift(@newcomponents,"");
74 $newlink=join('/',@newcomponents);
75 print "ln -sf $newlink $relfile\n";
77 symlink($newlink,$relfile);