-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlibraries.es
More file actions
53 lines (48 loc) · 994 Bytes
/
libraries.es
File metadata and controls
53 lines (48 loc) · 994 Bytes
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
#!/usr/local/bin/es
options = $options libs
# es library search path support. This will allow users to share
# libraries globally on a system.
corelib = '/usr/local/share/es/'
libraries = ()
enable-import = 'yes'
fn import-core-lib lib {
dprint 'import-core-lib exec''d'
let(libname = <={access -n $lib -1 -r $corelib}) {
if {! ~ $#libname 0} {
dprint 'loading '^$corelib^$lib
. $corelib^$lib
return 0
} {
return 1
}
}
}
fn import-user-lib lib {
dprint 'import-user-lib-exec''d'
if {~ $#libraries 0} {
dprint '$libraries not set'
return 1
}
catch @ e {
return 1
} {
let (libname = <={access -n $lib -1 -r $libraries}){
if {~ $#libname 0} { throw error }
. $libname
}
}
}
fn import lib {
if {~ $#enable-import 0} {
panic 'import' 'import is not enabled'
return 1
}
if {~ <={import-user-lib $lib} 0} {
dprint 'no userlib named '^$lib
if {~ <={import-core-lib $lib} 0} {
panic 'import' $lib^' not found'
return 1
}
}
return 0
}