summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-09-27 18:05:33 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-09-27 18:05:33 -0400
commit9c2bf6a2f6885d4f6373b5a682d10c40c84b4e66 (patch)
tree5f05a369009c1cf68eb84d683c94b160bbf551c8
parent39bc764104ad5268b9312a7ff49ff10d7907dd6b (diff)
downloadmoreutils-9c2bf6a2f6885d4f6373b5a682d10c40c84b4e66.tar.gz
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)
-rw-r--r--debian/changelog8
-rwxr-xr-xzrun26
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 <joeyh@debian.org> 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 <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)