summaryrefslogtreecommitdiff
path: root/bin/checklinks
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2009-03-08 22:27:07 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2009-03-08 22:27:07 +0100
commitc6795cae8dd0f3dac2abbdbb6d7bc49ed45b941c (patch)
treeefb36f4628929ae13010103ca38e9500e2ec05c5 /bin/checklinks
parent99b92f9c6fd19e1753e958aae3c62b7660f46e6e (diff)
Support $package and $etc in links file
Diffstat (limited to 'bin/checklinks')
-rwxr-xr-xbin/checklinks11
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) {