blob: 747230c36a6b32b1a377fca01f3e8b9b0087e52a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
implementation module hunt
// $Id$
/*
>|| Literal script "hunt.lit"
> %export
> findfiles
> glob
> readable
> writable
> getpath
> expand
> %include "basic.lit"
> findfiles :: ([char]->bool) -> [[char]] -> [[char]] -> [char] -> [[char]]
> findfiles goodmode exts paths base
> = filter (goodmode.filemode) (expand exts paths base)
> relative :: [char] -> bool
> relative ('/':cs) = False
> relative ccs = True
> expand :: [[char]] -> [[char]] -> [char] -> [[char]]
> expand exts paths base
> = [path++'/':base++ext|path<-mkset paths;ext<-mkset exts], if relative base
> = [base++ext|ext<-mkset exts], otherwise
> readable :: [char] -> bool
> readable ('d':rwx) = False
> readable (d:'r':wx) = True
> readable drwx = False
> writable :: [char] -> bool
> writable "" = True
> writable ('d':rwx) = False
> writable (d:r:'w':x) = True
> writable drwx = False
> getpath :: [[char]] -> [char] -> [[char]]
> getpath syspath varname
> = foldr (fill syspath) [] (split ':' (getenv varname))
> fill syspath [] = (syspath++)
> fill syspath = (:)
> glob :: [char] -> [[char]]
> glob pattern
> = filter (~=[]) ((concat.map (split ' ').lines) stdout), if return=0
> = error ("glob: "++stderr), otherwise
> where (stdout,stderr,return) = system ("echo "++pattern)
*/
|