-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand-server
executable file
·67 lines (52 loc) · 1.79 KB
/
command-server
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
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env zsh
# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# Copyright (c) YEAR USER_NAME
# An example of type-agnostic script/function, i.e.: the file can be run as a +x
# script or as an autoload function.
# Bootstrap complete exec environment…
0=${${0:#$ZSH_ARGZERO}:-${(%):-%N}}
0=${${(M)0##/*}:-$PWD/${0#./}}
# … by loading common.snip.zsh.
source $0:h/lib/common.snip.zsh cmd-server $0:h
# Tilde expand for all directories.
CMD_COMMAND_PATH=${CMD_COMMAND_PATH//(#b)((#s)|:)\~([A-Za-z0-9_]#)/\
$( eval q="~$match[1]"; print -rn -- $q)}
# Load configuration file if properly given.
[[ -f $1 ]] && source $1 || \
{ [[ -n $1 ]] && msg {208}Error:{41} config $1 not found, ignoring…;}
#
# Pre-process the repositories filtering out incorrect ones.
#
# -T ties a comma separated scalar with an array.
local -TUx CMD_COMMAND_PATH in_src_dirs
local -TUx FILT_COMMAND_PATH src_dirs
local prj tpe prev_tpe outfile cmd cmd_name
integer i count lockfd exit_code
local -a tmp
local -A INI
csrv-filter-dirs 1 $in_src_dirs || exit 1
src_dirs=( $reply )
# Save the processed value and other Plugins hash fields.
Plugins[CMD_COMMAND_PATH]=$FILT_COMMAND_PATH
Plugins[CMD_CONF_INTERVAL]=${CMD_CONF_INTERVAL:=70}
#
# Main loop
#
while ((1)); do
sleep $Plugins[CMD_CONF_INTERVAL]
i=0
#
# Compile each of the projects and test their result,
# setting their private state files.
#
for prj in $src_dirs; do
i+=1
for cmd in $prj/*.(ini|cmd)(N); do
CMD_BG_RUN=1 $Plugins[CMD_LIBEXEC_DIR]/cmd-examine $cmd
exit_code=$?
msg {208}COMMAND-SERVER:%f Command $cmd of {39}$prj:%f \
examine with exit code $exit_code.
done
done
done
# vim:ft=zsh:tw=80:sw=4:sts=4:et:foldmarker=[[[,]]]