X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_zcat;h=9e21790d93db30dfe124f2575b4652adef320e6f;hp=284988ac0625b0f2aaa423d5f72cd0a259ef6124;hb=e951f787a66c5bd9e9955c3f657a5b44289c0fe1;hpb=e9453b7611be63303572ae443d5fb56b73364678 diff --git a/bin/BackupPC_zcat b/bin/BackupPC_zcat index 284988a..9e21790 100755 --- a/bin/BackupPC_zcat +++ b/bin/BackupPC_zcat @@ -1,4 +1,4 @@ -#!/bin/perl -T +#!/bin/perl #============================================================= -*-perl-*- # # BackupPC_zcat: uncompress files to stdout @@ -14,7 +14,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2001 Craig Barratt +# Copyright (C) 2001-2003 Craig Barratt # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -32,13 +32,14 @@ # #======================================================================== # -# Version 1.6.0_CVS, released 10 Dec 2002. +# Version 2.1.0, released 20 Jun 2004. # # See http://backuppc.sourceforge.net. # #======================================================================== use strict; +no utf8; use lib "/usr/local/BackupPC/lib"; use Compress::Zlib; @@ -47,28 +48,33 @@ use BackupPC::FileZIO; sub zcat { my($fh, $fileName) = @_; - my($data, $r); + my($data, $r, $ret); while ( ($r = $fh->read(\$data, 65536)) > 0 ) { print($data); } if ( $r < 0 ) { print(STDERR "$0: can't uncompress $fileName\n"); + $ret = 1; } $fh->close(); + return $ret; } +my $ret = 0; if ( @ARGV ) { while ( @ARGV ) { if ( defined(my $fh = BackupPC::FileZIO->open($ARGV[0], 0, 1)) ) { - zcat($fh, $ARGV[0]); + $ret ||= zcat($fh, $ARGV[0]); } else { print(STDERR "$0: can't open $ARGV[0]\n"); - exit(1); + $ret = 1; + last; } shift @ARGV; } } else { my $fh = BackupPC::FileZIO->open(*STDIN, 0, 1); - zcat($fh, "stdin"); + $ret ||= zcat($fh, "stdin"); } +exit($ret);