~ chicken-core (chicken-5) 46835db3aed28d387a0c5b3874c138262d3798ba


commit 46835db3aed28d387a0c5b3874c138262d3798ba
Author:     Evan Hanson <evhan@foldling.org>
AuthorDate: Mon Aug 27 18:13:34 2018 +1200
Commit:     Kooda <kooda@upyum.com>
CommitDate: Mon Aug 27 21:24:54 2018 +0200

    Fix error in "chicken-status -cached" due to `map' with string argument
    
    In 7a7d0be0 we added a clause to `list-egg-info' that maps over its
    `dir' argument, but that may be reached when `dir' is a string (causing
    an error). This procedure only actually needs to handle two cases,
    installed egg-info files and egg or VERSION files in the cache, so we
    simplify the procedure to fix this bug and remove some redundant logic.
    
    Signed-off-by: Kooda <kooda@upyum.com>

diff --git a/chicken-status.scm b/chicken-status.scm
index e145e32a..93e0a161 100644
--- a/chicken-status.scm
+++ b/chicken-status.scm
@@ -110,19 +110,11 @@
 
   (define (list-egg-info egg dir ext)
     (let ((version
-	    (cond ((let ((info (read-info egg dir ext)))
-		     (and info (get-egg-property info 'version))))
-		  ((and (string? dir)
-			(file-exists? (make-pathname (list dir egg) +version-file+)))
-		   => (lambda (fname)
-			(with-input-from-file fname read)))
-		  ((chicken.load#find-file +version-file+
-					   (map (lambda (d)
-						  (make-pathname d egg))
-						dir))
-		   => (lambda (fname)
-			(with-input-from-file fname read)))
-		  (else "unknown"))))
+	   (or (let ((info (read-info egg dir ext)))
+		 (and info (get-egg-property info 'version)))
+	       (let ((file (chicken.load#find-file +version-file+ dir)))
+		 (and file (with-input-from-file file read)))
+	       "unknown")))
       (print (format-string (string-append egg " ")
 			    list-width #f #\.)
 	     (format-string (string-append " version: "
@@ -133,7 +125,7 @@
     (when (directory-exists? cache-directory)
       (for-each
        (lambda (egg)
-	 (list-egg-info egg cache-directory +egg-extension+))
+	 (list-egg-info egg (make-pathname cache-directory egg) +egg-extension+))
        (sort (filter-egg-names (directory cache-directory) pats mtch) string<?))))
 
   (define (gather-components lst mode)
Trap