From c6795cae8dd0f3dac2abbdbb6d7bc49ed45b941c Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 8 Mar 2009 22:27:07 +0100 Subject: Support $package and $etc in links file --- bin/checklinks | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'bin/checklinks') diff --git a/bin/checklinks b/bin/checklinks index 5016aba..442cf10 100755 --- a/bin/checklinks +++ b/bin/checklinks @@ -3,12 +3,14 @@ ## License: WTFPL use strict; use warnings; +use Getopt::Long; use Term::ANSIColor; my $base = $ENV{HOME}; my ($type, $src, $dst); my $quiet = 0; my $remove = 0; +my %substitute; my $linkfile; if (-f '.links') { @@ -19,6 +21,12 @@ if (-f '.links') { exit(0); } +GetOptions( + 'q|quiet' => \$quiet, + 'r|remove' => \$remove, + 'p|parameter=s' => \%substitute, +); + if (defined($ARGV[0])) { if ($ARGV[0] eq '-q') { $quiet = 1; @@ -31,6 +39,9 @@ if (defined($ARGV[0])) { open(LINKS, '<', $linkfile) or die($!); while() { chomp; + foreach my $key (keys(%substitute)) { + s/\$$key/$substitute{$key}/g; + } ($type, $src, $dst) = split; next unless ($type eq 'soft' or $type eq 'hard'); if ($remove) { -- cgit v1.2.3