#!/usr/bin/perl -w # Program to install links if necessary (does nothing if already there) # $Id: install-links,v 1.3 1999/12/31 06:13:17 earl Exp $ # Copyright (c) 2000 by Earl A. Killian. All Rights Reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; see the file COPYING. If not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, # MA 02111-1307, USA. package installlinks; use strict; use Getopt::Long; use File::Basename; { $::myname = 'install-links'; my $nodo = 0; my $verbose = 1; die ("Usage is: $::myname [-n] files...\n") unless GetOptions ("n!" => \$nodo, "v!" => \$verbose) && @ARGV > 0; my $to; foreach $to (@ARGV) { my ($name, $path) = fileparse($to); my $current = readlink($name); if (!defined($current) || $current ne $to) { if (!$nodo) { unlink ($name); symlink ($to, $name) || die("$::myname: $!, symlinking $name to $to.\n"); } print STDOUT ("$::myname: Info: linked $name to $to.\n") if $verbose; } } } # Local Variables: # mode:perl # perl-indent-level:2 # cperl-indent-level:2 # End: