diff --git a/bin/tar b/bin/tar index bc99a048..994c1e78 100755 --- a/bin/tar +++ b/bin/tar @@ -20,27 +20,13 @@ use IO::File; use constant EX_SUCCESS => 0; use constant EX_FAILURE => 1; -use vars qw($opt); - my $Program = basename($0); -BEGIN - { - $opt = 'ctxvmf:'; - eval { require Compress::Zlib }; - if ($@) - { - warn "No decompression available: $@\n"; - } - else - { - Compress::Zlib->import; - $opt .= 'zZ'; - } - } - my %opt; -getopts($opt,\%opt); +getopts('ctxvmf:Zz', \%opt) or do { + warn "usage: tar {-tx} [-mvZz] [-f archive] [file ...]\n"; + exit EX_FAILURE; +}; sub fatal { @@ -225,7 +211,8 @@ else if ($opt{'z'} || $opt{'Z'}) { - # quick and dirty till we sort out Compress::Zlib + eval { require Compress::Zlib } or fatal('Compress::Zlib not found'); + Compress::Zlib->import; my $gz = gzopen($fh, 'rb') or fatal("Cannot gzopen: $Compress::Zlib::gzerrno"); $read = sub { $gz->gzread($_[0],$_[1]) < 0 ? $Compress::Zlib::gzerrno : 0 }; }