-
Notifications
You must be signed in to change notification settings - Fork 0
/
olint
executable file
·60 lines (46 loc) · 1.11 KB
/
olint
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
#!/usr/bin/env bash
set -e
olint_usage() {
echo "Usage: olint command"
exit 1
}
[[ -z "$1" ]] && olint_usage
index=${OLINT_INDEX:-0}
olint_log="olint.${index}.log"
export OLINT_INDEX=$((index + 1))
capture_stdout() {
while IFS= read -r line || [ "$line" ]; do
time=$(date +%s%N)
echo "$line"
echo "O ${time} ${line}" >> "${olint_log}"
done && true
}
capture_stderr() {
while IFS= read -r line || [ "$line" ]; do
time=$(date +%s%N)
>&2 echo "$line"
echo "E ${time} ${line}" >> "olint.${index}.log"
done && true
}
olint_exec() {
#echo "[olint] Open stdout."
#>&2 echo "[olint] Open stderr."
eval "$@ && true"
#echo "[olint] Close stdout."
#>&2 echo "[olint] Close stderr."
}
olint_input() {
a=1
}
olint_check() {
echo "============================================================="
}
input_file="$1.input"
[ -f "olint.${index}.log" ] && rm -f "olint.${index}.log"
if [[ -f "${input_file}" ]]; then
olint_exec "$@" && true < <(olint_input) > >(capture_stdout) 2> >(capture_stderr)
else
olint_exec "$@" && true > >(capture_stdout) 2> >(capture_stderr)
fi
sleep 1
olint_check