diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2009-03-08 22:27:07 +0100 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2009-03-08 22:27:07 +0100 |
commit | c6795cae8dd0f3dac2abbdbb6d7bc49ed45b941c (patch) | |
tree | efb36f4628929ae13010103ca38e9500e2ec05c5 /bin/checklinks | |
parent | 99b92f9c6fd19e1753e958aae3c62b7660f46e6e (diff) |
Support $package and $etc in links file
Diffstat (limited to 'bin/checklinks')
-rwxr-xr-x | bin/checklinks | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/bin/checklinks b/bin/checklinks index 5016aba..442cf10 100755 --- a/bin/checklinks +++ b/bin/checklinks @@ -3,12 +3,14 @@ ## License: WTFPL <http://sam.zoy.org/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(<LINKS>) { 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) { |