diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/remote/print.sh | 26 | ||||
-rw-r--r-- | lib/remote/report.sh | 27 |
2 files changed, 43 insertions, 10 deletions
diff --git a/lib/remote/print.sh b/lib/remote/print.sh index a0fdcbe..ef9c9b8 100644 --- a/lib/remote/print.sh +++ b/lib/remote/print.sh @@ -130,9 +130,33 @@ function print_hline { echo | eol } +acolumn() { + local sep="$1" out="$2" + awk -v FS="$sep" -v SEP="$out" -v OFS='' ' + function strip(s) { gsub(/\x1B\[[0-9;?]*[ -/]*[@-~]/, "", s); return s } + { + rows[NR] = $0 + if (NF > cols) cols = NF + for (i = 1; i <= NF; i++) + if (length(strip($i)) > w[i]) w[i] = length(strip($i)) + } + END { + for (r = 1; r <= NR; r++) { + n = split(rows[r], a, FS) + for (i = 1; i <= n; i++) { + pad = w[i] - length(strip(a[i])) + printf "%s%*s", a[i], (i < n ? pad : 0), "" + if (i < n) printf "%s", SEP + } + print "" + } + }' +} + function print_table { # The problem here is that all escapes for colors are treated as normal visible symbols - sed "s/ ::: /@/g" | column -t -s "@" -o " " | eol +# sed "s/ ::: /@/g" | column -t -s "@" -o "x x" --output-width 0 | eol + sed "s/ ::: /@/g" | acolumn "@" " " | eol } function decorate_table { diff --git a/lib/remote/report.sh b/lib/remote/report.sh index 434c6aa..c4373a3 100644 --- a/lib/remote/report.sh +++ b/lib/remote/report.sh @@ -3,13 +3,22 @@ function simple_report { 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 +# { +# 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" + } @@ -30,7 +39,7 @@ function standart_report { configure_palete "$palete" simple_report "$generator" "$filter" - print "$report" + print "$report_text" echo finish } @@ -38,7 +47,7 @@ function standart_report { function report { # Eval breaks output for some reason - case $report in + case $report_style in simple_report) simple_report "$@" ;; |