blob: c4373a3d20cff62cd0e47b0c2a4c47b03c572ba9 (
plain)
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
|
function simple_report {
local generator="$1"
local filter="${2:-cat}"
# Create fd12 (sending empty output), execute checks (writting extra info on fd12), print main info and store extra info into variable, wait for termination of async checks.
# {
# chmod +w /dev/fd/12
# eval "$generator 12>/dev/fd/12 | $filter"
# report=$(cat<&12)
# } 12<<EOF
#EOF
# wait
fifo=$(mktemp -u) ; mkfifo "$fifo"
eval "$generator 12>$fifo | $filter" &
genpid=$!
report_text=$(cat "$fifo")
wait "$genpid"
rm -f "$fifo"
}
function short_report {
local generator="$1"
local filter="${2:-print_table | decorate_table}"
configure_palete "$palete"
simple_report "$generator" "$filter"
finish
}
function standart_report {
local generator="$1"
local filter="${2:-print_table | decorate_table}"
configure_palete "$palete"
simple_report "$generator" "$filter"
print "$report_text"
echo
finish
}
function report {
# Eval breaks output for some reason
case $report_style in
simple_report)
simple_report "$@"
;;
short_report)
short_report "$@"
;;
standart_report)
standart_report "$@"
;;
default)
echo "Report is not implemented"
esac
}
|