-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathzgenom-compile
executable file
·50 lines (44 loc) · 1.46 KB
/
zgenom-compile
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
#!/usr/bin/env zsh
function __zgenom_compile() {
if [[ ! -f $file.zwc || $file -nt $file.zwc ]] && [[ -r $file ]]; then
zcompile $opts $file
fi
}
function zgenom-compile() {
local opts=()
zparseopts -a opts -D -- M R U k z || return
if [[ $# -eq 0 ]]; then
__zgenom_err '`compile` requires one parameter:'
__zgenom_err '`zgenom compile <location>`'
fi
local file
while [[ $# -gt 0 ]]; do
file=$1; shift
if [ -f $file ]; then
__zgenom_compile
else
# only files, ignore compiled files and ignore .git folders
for file in $file/**/*~*/.git/*~*.zwc(.DN); do
# Check *.sh if it can be parsed from zsh
if [[ $file = *.sh ]]; then
if ! zsh -n $file 2>/dev/null; then
continue
fi
# Check for shebang if not:
# - zsh startup file
# - *.zsh
# - zcompdump*
elif [[ $file != *.zsh ]] \
&& [[ $file != *zcompdump* ]] \
&& [[ ! $file =~ '\.z(shenv|profile|shrc|login|logout)$' ]]; then
read -r firstline < $file
if [[ ! $firstline =~ '^#!.*zsh' ]] 2>/dev/null; then
continue
fi
fi
__zgenom_compile
done
fi
done
}
zgenom-compile $@