summaryrefslogtreecommitdiff
path: root/zrun
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 /zrun
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)
Diffstat (limited to 'zrun')
-rwxr-xr-xzrun26
1 files changed, 21 insertions, 5 deletions
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)