From 9c2bf6a2f6885d4f6373b5a682d10c40c84b4e66 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 27 Sep 2008 18:05:33 -0400 Subject: [PATCH] zrun: Can be linked to zsomeprog to run the equivilant of zrun someprog. * zrun: Can be linked to zsomeprog to run the equivilant of zrun someprog. Closes: #411623 (Stefan Fritsch) * zrun: Add support for lzma and lzo. (Stefan Fritsch) --- debian/changelog | 8 ++++++++ zrun | 26 +++++++++++++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/debian/changelog b/debian/changelog index 9ed8b7d..1e67c6e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +moreutils (0.32) UNRELEASED; urgency=low + + * zrun: Can be linked to zsomeprog to run the equivilant of zrun someprog. + Closes: #411623 (Stefan Fritsch) + * zrun: Add support for lzma and lzo. (Stefan Fritsch) + + -- Joey Hess Sat, 27 Sep 2008 18:03:48 -0400 + moreutils (0.31) unstable; urgency=low * pee.1: Document difference with tee in stdout. diff --git a/zrun b/zrun index 7776db2..cedfbae 100755 --- a/zrun +++ b/zrun @@ -17,6 +17,11 @@ arguments of the command to be transparently uncompressed to temp files 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 IO::Handle; use File::Spec; use File::Temp qw{tempfile}; -my $program = shift; +my $program; -if (! @ARGV) { - die "Usage: zrun \n"; +if ($0 =~ m{(?:^|/)z([^/]+)$}) { + $program = $1; + if (! @ARGV) { + die "Usage: z$1 \nEquivalent to: zrun $1 \n"; + } +} +else { + $program = shift; + if (! @ARGV) { + die "Usage: zrun \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) -- 2.39.5