add version subroutine
authorChristian Arnold <arnold@schlittermann.de>
Sat, 12 Feb 2011 12:54:11 +0100
changeset 2 2be9944bc67b
parent 1 52edcba85acf
child 3 0de455fc3f4e
add version subroutine exit if no filesystem is specified change to version 0.2
check_fsck.pl
--- a/check_fsck.pl	Mon Jan 31 21:07:11 2011 +0100
+++ b/check_fsck.pl	Sat Feb 12 12:54:11 2011 +0100
@@ -26,8 +26,8 @@
 use Getopt::Long;
 use Date::Manip;
 
-delete @ENV{grep /^LC_/ => keys %ENV};
-$ENV{LANG} = "C";
+delete @ENV{ grep /^LC_/ => keys %ENV };
+$ENV{LANG}   = "C";
 $ENV{LC_ALL} = "C";
 
 my %ERRORS = (
@@ -39,10 +39,11 @@
 );
 
 my $ME      = basename $0;
-my $VERSION = "0.1";
+my $VERSION = "0.2";
 
 sub get_status($);
 sub report($);
+sub version($$);
 
 my %opt = (
     fs        => undef,
@@ -67,6 +68,8 @@
         "V|version" => sub { version( $ME, $VERSION ); exit $ERRORS{OK}; }
     ) or pod2usage( -verbose => 1, -exitval => $ERRORS{CRITICAL} );
 
+    $opt{fs} // pod2usage( -verbose => 1, -exitval => $ERRORS{CRITICAL} );
+
     ### %opt
 
     report( get_status( $opt{fs} ) );
@@ -123,7 +126,8 @@
 
     foreach my $fs (@fs) {
         unless ( -b -r $fs ) {
-            say "FSCK CRITICAL $fs - not a block device or no read permission is granted";
+            say
+"FSCK CRITICAL $fs - not a block device or no read permission is granted";
             exit $ERRORS{CRITICAL};
         }
         foreach (
@@ -169,6 +173,18 @@
     return \%values;
 }
 
+sub version($$) {
+    my ( $progname, $version ) = @_;
+    print <<_VERSION;
+$progname version $version
+Copyright (C) 2011 by Christian Arnold and Schlittermann internet & unix support.
+
+$ME comes with ABSOLUTELY NO WARRANTY. This is free software,
+and you are welcome to redistribute it under certain conditions.
+See the GNU General Public Licence for details.
+_VERSION
+}
+
 __END__
 
 =head1 NAME
@@ -237,7 +253,7 @@
 
 =head1 VERSION
 
-This man page is current for version 0.1 of check_fsck.
+This man page is current for version 0.2 of check_fsck.
 
 =head1 AUTHOR