~ chicken-core (chicken-5) 617d2dee613a1c48e27a1d9c72927763f895e0f2


commit 617d2dee613a1c48e27a1d9c72927763f895e0f2
Author:     Mario Domenech Goulart <mario@parenteses.org>
AuthorDate: Thu Apr 1 21:11:34 2021 +0200
Commit:     Peter Bex <peter@more-magic.net>
CommitDate: Fri Apr 9 16:26:12 2021 +0200

    egg-download: handle eof in read-chunks
    
    Handle eof objects that might be returned by `read-line' in
    `read-chunks', in which cases `string->number' would break, causing
    the errors that we sometimes observe in salmonella jobs (see #1744).
    
    Hopefully fixes #1744
    
    Signed-off-by: Peter Bex <peter@more-magic.net>

diff --git a/NEWS b/NEWS
index 18c225c5..7a2373c0 100644
--- a/NEWS
+++ b/NEWS
@@ -51,6 +51,9 @@
     still requires PLATFORM to be set, and it can still be provided
     manually, but it is no longer required in the common case.
 
+- Tools
+  - Fixed a bug in chicken-install (#1744) that would cause
+    `Error: (string->number) bad argument type: #!eof` in some cases.
 
 5.2.0
 
diff --git a/egg-download.scm b/egg-download.scm
index 9906ca89..dc97b376 100644
--- a/egg-download.scm
+++ b/egg-download.scm
@@ -208,7 +208,9 @@
 
 (define (read-chunks in)
   (let get-chunks ((data '()))
-    (let ((size (string->number (read-line in) 16)))
+    (let* ((line (read-line in))
+           (size (and (not (eof-object? line))
+                      (string->number line 16))))
       (cond ((not size)
 	       (error "invalid response from server - please try again"))
             ((zero? size)
Trap