#!/usr/bin/perl use File::Basename; # TODO make this configurable or something my $term = 'terminal'; # follow a link to its subdirectory and open a shell and etc # we behave exactly like svn except we insist on reading links # XXX (must we really insist on reading links?) # (just Cwd::abs_path() everything?) my ($command, $link) = (shift, shift) or die "usage: $0 \n"; (-l $link) or warn "'$link' is not a symlink\n"; my $file = $link; while(my $t = readlink($link)) { ## or die "could not readlink '$link' ($!)\n"; $file = $t; $link = $t; } (-e $file) or die "target: '$file' does not exist\n"; # XXX what about directories? (-f $file) or die "'$file' is not a regular file\n"; (-l $file) and die "'$file' is just a link\n"; print "target is '$file'\n\n"; print "svn $command $file @ARGV\n"; if($command eq "shell") { my $dir = dirname($file); chdir($dir) or die "cannot enter $dir\n"; fork() && exit; exec($term); } else { my $dir = dirname($file); my $filename = basename($file); chdir($dir); exec("svn", $command, $filename, @ARGV); }