[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

It would be nice if glob "/*/*" worked

From: Matt Welland
Subject: It would be nice if glob "/*/*" worked
Date: Thu, 21 Nov 2019 03:25:23 -0700

Supporting glob patterns at any level would be handy. I started to implement something which I've included below but before I complete it:

1. Is there a multi-level glob implementation in some other egg? The glob that comes with posix only handles the pattern in the top level. I didn't find anything in searching the eggs.

2. Does anyone have an implementation they can share?

3. If I complete the implementation below can it be added to posix or should I create an egg?

(define (multi-glob pathspec)
  (let* ((path-parts (string-split pathspec "/" #t)))
    (if (null? path-parts)
        (let loop ((parts  (cdr path-parts))
                   (result (let ((p (car path-parts)))
                             (if (string=? p "")
                                 (glob (car path-parts))))))
          (if (null? parts)
              (let* ((part (car parts))
                     (rem  (cdr parts)))
                (loop rem
                      (apply append
                             (map (lambda (curr)
                                    (let ((new (string-append curr "/" part)))
                                      (if (and (directory? curr)
                                               (file-read-access? curr))
                                          (glob new)

Complexity is your enemy. Any fool can make something complicated.
It is hard to keep things simple. - Richard Branson.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]