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

2019-11-29 Thread Matt Welland
On Fri, Nov 29, 2019 at 2:59 AM Tim via  wrote:

> Hi Matt,
>
> Matt Welland writes:
> > Supporting glob patterns at any level would be handy. I started to
> > implement something which I've included below but before I complete it:
>
> I like this idea too.  Just one thing: would it be possible to use the
> double-asterisk ** instead of a single * to represent the directory
> matching portion?  I.e.  /subdir/**/*.txt would find any file with a
> name ending in .txt in any directory below /subdir. This is a pretty
> common syntax for recursive globbing I think; at least I've seen it in
> zsh, python and a few other places.
>

I don't understand the use or benefit of using ** for directories. Bash,
perl and python all expand "*/c*" as I would expect. Can you send a pointer
to the usage you are referring to?


>
> Tim
>


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


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

2019-11-29 Thread Tim via
Hi Matt,

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

I like this idea too.  Just one thing: would it be possible to use the
double-asterisk ** instead of a single * to represent the directory
matching portion?  I.e.  /subdir/**/*.txt would find any file with a
name ending in .txt in any directory below /subdir. This is a pretty
common syntax for recursive globbing I think; at least I've seen it in
zsh, python and a few other places.

Tim


signature.asc
Description: PGP signature


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

2019-11-28 Thread Evan Hanson
On 2019-11-28  8:38, Kristian Lein-Mathisen wrote:
> I may be missing the point here, but is'nt it just easier to use find-files?

I think there are situations where one is more natural than the other.

find-files is strictly more powerful, but it's not as concise or
readable for many use cases so I'm considering the limitations of the
glob procedure independently.

Best,

Evan



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

2019-11-27 Thread Kristian Lein-Mathisen
I may be missing the point here, but is'nt it just easier to use find-files?

http://wiki.call-cc.org/man/5/Module%20(chicken%20file)#find-files

K.

On Wed, Nov 27, 2019, 23:32 Evan Hanson  wrote:

> Hi Matt,
>
> This would be nice indeed, I've also found myself wanting this feature
> before. I don't know of an existing solution, but I think it would be
> best if we made it "just work" with the existing glob procedure.
>
> I've created a ticket for that: https://bugs.call-cc.org/ticket/1657
>
> Cheers,
>
> Evan
>


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

2019-11-27 Thread Evan Hanson
Hi Matt,

This would be nice indeed, I've also found myself wanting this feature
before. I don't know of an existing solution, but I think it would be
best if we made it "just work" with the existing glob procedure.

I've created a ticket for that: https://bugs.call-cc.org/ticket/1657

Cheers,

Evan


signature.asc
Description: PGP signature


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

2019-11-21 Thread Matt Welland
Improved version:

(define (multi-glob pathspec)
  (let* ((path-parts (intersperse (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)
 result
 (let* ((part (car parts))
(rem  (cdr parts)))
(loop rem
 (apply append
(map (lambda (curr)
   (let ((new (string-append curr part)))
 (cond
  ((and (directory? curr)(file-read-access? curr))
(glob new))
  ((member part '("." ".." "/")) new)
  (else '()
 result)

On Thu, Nov 21, 2019 at 3:25 AM Matt Welland  wrote:

> 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)
>   result
>   (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)
>   '(
>   result)
> ~
>
> ~
>
> --
> --
> Complexity is your enemy. Any fool can make something complicated.
> It is hard to keep things simple. - Richard Branson.
>


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


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

2019-11-21 Thread Matt Welland
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)
  result
  (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)
  '(
  result)
~

~

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