aboutsummaryrefslogtreecommitdiffstats
path: root/interimap
diff options
context:
space:
mode:
Diffstat (limited to 'interimap')
-rwxr-xr-xinterimap12
1 files changed, 8 insertions, 4 deletions
diff --git a/interimap b/interimap
index 6442054..a94110b 100755
--- a/interimap
+++ b/interimap
@@ -51,10 +51,12 @@ sub usage(;$) {
}
exit $rv;
}
-usage(1) unless GetOptions(\%CONFIG, qw/config=s quiet|q target=s@ debug help|h repair delete rename/);
+
+my @COMMANDS = qw/repair delete rename/;
+usage(1) unless GetOptions(\%CONFIG, qw/config=s quiet|q target=s@ debug help|h/, @COMMANDS);
usage(0) if $CONFIG{help};
my $COMMAND = do {
- my @command = grep {exists $CONFIG{$_}} qw/repair delete rename/;
+ my @command = grep {exists $CONFIG{$_}} @COMMANDS;
usage(1) if $#command>0;
$command[0]
};
@@ -200,7 +202,8 @@ $DBH->do('PRAGMA foreign_keys = ON');
sub msg($@) {
my $name = shift;
return unless @_;
- logger($name, @_) if defined $LOGGER_FD and $LOGGER_FD->fileno != fileno STDERR;
+ logger($name, @_) if defined $LOGGER_FD and defined $LOGGER_FD->fileno
+ and $LOGGER_FD->fileno != fileno STDERR;
my $prefix = defined $name ? "$name: " : '';
print STDERR $prefix, @_, "\n";
}
@@ -208,7 +211,8 @@ sub logger($@) {
my $name = shift;
return unless @_ and defined $LOGGER_FD;
my $prefix = '';
- if ($LOGGER_FD->fileno != fileno STDERR) {
+ if (defined $LOGGER_FD and defined $LOGGER_FD->fileno
+ and $LOGGER_FD->fileno != fileno STDERR) {
my ($s, $us) = Time::HiRes::gettimeofday();
$prefix = POSIX::strftime("%b %e %H:%M:%S", localtime($s)).".$us ";
}