----- Begin Included Message -----

>From rmb1 Wed May 16 18:22:22 2001
To: [EMAIL PROTECTED]
Subject: patch to lwp-download
X-Sun-Charset: US-ASCII
Content-Length: 1313

Gisle

If lwp-download is interupted before it has received anything
ugly messages appear:

    0 bytes receivedUse of uninitialized value at /usr/local/bin/lwp-download 
    line 174.
     in 275009 hours 19 minutes (0 bytes/sec)
    Use of uninitialized value at /usr/local/bin/lwp-download line 183.
    Transfer aborted.  Delete ? [n] y
    Use of uninitialized value at /usr/local/bin/lwp-download line 185, <STDIN> 
    chunk 1.

This is because $file and $start_t do not get set.  
Patch below.

Robin

--- lwp-download.PL.orig       
+++ lwp-download.PL
@@ -183,15 +183,18 @@
     print fbytes($size);
     print " of ", fbytes($length) if defined($length) && $length != $size;
     print " received";
-    my $dur = time - $start_t;
+    my $dur = defined $start_t ? time - $start_t : 0;
     if ($dur) {
        my $speed = fbytes($size/$dur) . "/sec";
        print " in ", fduration($dur), " ($speed)";
     }
-    print "\n";
+    print ".\n";
     my $died = $res->header("X-Died");
     if ($died || !$res->is_success) {
-       if (-t) {
+       unless( defined $file ) {
+           print "Transfer aborted.\n";
+       } 
+       elsif (-t) {
            print "Transfer aborted.  Delete $file? [n] ";
            my $ans = <STDIN>;
            unlink($file) if defined($ans) && $ans =~ /^y\n/;


----- End Included Message -----


-- 
Robin Barker                        | Email: [EMAIL PROTECTED]
CMSC, Building 10,                  | Phone: +44 (0) 20 8943 7090
National Physical Laboratory,       | Fax:   +44 (0) 20 8977 7091
Teddington, Middlesex, UK. TW11 OLW | WWW:   http://www.npl.co.uk

Reply via email to