tags 411623 patch
thanks
The attached patch implements this feature (and adds support for lzma and
lzo).--- /usr/bin/zrun 2008-06-29 05:22:20.000000000 +0200
+++ zrun 2008-09-27 23:07:42.000000000 +0200
@@ -17,6 +17,11 @@
This is a quick way to run a command that does not itself support
compressed files, without manually uncompressing the files.
+The following compression types are supported: gz bz2 Z lzma lzo
+
+If zrun is linked to some name beginning with z, like zprog, and the link is
+executed, this is equivalent to executing "zrun prog".
+
=head1 BUGS
Modifications to the uncompressed temporary file are not fed back into the
@@ -35,18 +40,29 @@
use File::Spec;
use File::Temp qw{tempfile};
-my $program = shift;
+my $program;
-if (! @ARGV) {
- die "Usage: zrun <command> <args>\n";
+if ($0 =~ m{(?:^|/)z([^/]+)$}) {
+ $program = $1;
+ if (! @ARGV) {
+ die "Usage: z$1 <args>\nEquivalent to: zrun $1 <args>\n";
+ }
+}
+else {
+ $program = shift;
+ if (! @ARGV) {
+ die "Usage: zrun <command> <args>\n";
+ }
}
my @argument;
my %child;
foreach my $argument (@ARGV) {
- if ($argument =~ m{^(.*/)?([^/]*)\.(gz|Z|bz2)$}s) {
+ if ($argument =~ m{^(.*/)?([^/]*)\.(gz|Z|bz2|lzo|lzma)$}s) {
my $suffix = "-$2";
- my @preprocess = $3 eq "bz2" ? qw(bzip2 -d -c) : qw(gzip -d -c);
+ my @preprocess = $3 eq "bz2" ? qw(bzip2 -d -c) :
+ $3 eq "lzo" ? qw(lzop -d -c) :
+ $3 eq "lzma" ? qw(lzma -d -c) : qw(gzip -d -c);
my ($fh, $tmpname) = tempfile(SUFFIX => $suffix,
DIR => File::Spec->tmpdir, UNLINK => 1)