about summary refs log tree commit diff
diff options
context:
space:
mode:
authorArun Isaac2026-11-07 01:44:39 +0000
committerArun Isaac2026-11-07 01:44:39 +0000
commitb5e1e011b8177faa3fcafe732990cb7f83744c29 (patch)
tree527ace37e6ce016deda8a41e9e97dfcf496f23d7
parent330d89641c4dc5372b787f5db3a0fec657b0c790 (diff)
downloadkaagum-b5e1e011b8177faa3fcafe732990cb7f83744c29.tar.gz
kaagum-b5e1e011b8177faa3fcafe732990cb7f83744c29.tar.lz
kaagum-b5e1e011b8177faa3fcafe732990cb7f83744c29.zip
Protect against system errors when searching files.
-rw-r--r--kaagum/tools/base.scm30
1 files changed, 18 insertions, 12 deletions
diff --git a/kaagum/tools/base.scm b/kaagum/tools/base.scm
index 84ce9d6..f05ed6b 100644
--- a/kaagum/tools/base.scm
+++ b/kaagum/tools/base.scm
@@ -205,20 +205,26 @@ For example, to match all scheme (.scm) files, use \"\\.scm$\"")))
                                                        "~a:~a:~a~%"
                                                        file line-number line))))))
                    (for-each (lambda (file)
-                               (call-with-input-file file
-                                 (cut port-transduce
-                                      (compose (tenumerate 1)
-                                               (tfilter line-matcher)
-                                               (tlog (make-line-logger file)))
-                                      (const #t)
-                                      get-line
-                                      <>)))
+                               ;; Abort file if any system error occurred.
+                               (false-if-exception
+                                (call-with-input-file file
+                                  (cut port-transduce
+                                       (compose (tenumerate 1)
+                                                (tfilter line-matcher)
+                                                (tlog (make-line-logger file)))
+                                       (const #t)
+                                       get-line
+                                       <>))))
                              (filter (lambda (file)
                                        ;; Ensure file is a regular file and is
-                                       ;; not binary.
-                                       (and (eq? (stat:type (stat file))
-                                                 'regular)
-                                            (not (binary-file? file))))
+                                       ;; not binary. But, reject file if any
+                                       ;; system error (such as permission,
+                                       ;; non-existence, etc.) was encountered
+                                       ;; during test.
+                                       (false-if-exception
+                                        (and (eq? (stat:type (stat file))
+                                                  'regular)
+                                             (not (binary-file? file)))))
                                      (files-recursively files-root files-pattern)))))
         #:title (lambda* (#:key pattern files-root files-pattern)
                   (if files-pattern