| my $operation = shift @ARGV; |
| if ($operation !~ m/^(install|uninstall)$/) { |
| print STDERR "$0: unknown operation $operation\n"; |
| if ($arg =~ m/([^=]*)=(.*)/) { |
| print STDERR "$0: can't parse option [$arg]\n"; |
| for my $option (qw(command directory extension file)) { |
| unless (defined($options{$option})) { |
| print STDERR "$0: required variable $option not provided\n"; |
| unless (open $fh, '<', $options{file}) { |
| print STDERR "$0: can't open links file '$options{file}': $!"; |
| my @cmd = split /\s+/, $options{command}; |
| while (my $line = <$fh>) { |
| my @args = split /\s+/, $line; |
| my ($source, @destinations) = @_; |
| if ($operation eq 'install') { |
| push @args, "$options{directory}/$source.$options{extension}"; |
| for my $destination (@destinations) { |
| push @args, "$options{directory}/$destination.$options{extension}"; |
| print STDERR "$0: command failed: $?\n"; |