dot

packages and services management
Log | Files | Refs | README

commit e136450667f39247b0f6526a154987b50c0741ea
parent 80668990ab40cb0b1b8a2dcd124697469cc9a16f
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Fri,  4 Aug 2017 09:46:38 +0200

shell/bin/ii-filter: I will have to fix those some day

Diffstat:
Mii/bin/ii-filter | 43++++++++++++++++++++++---------------------
Dii/bin/ii-filter-sed | 61-------------------------------------------------------------
2 files changed, 22 insertions(+), 82 deletions(-)

diff --git a/ii/bin/ii-filter b/ii/bin/ii-filter @@ -3,51 +3,52 @@ awk ' BEGIN { - WIDTH = 80 - 17; + WIDTH = 80 - 17 } date != $1 { - printf("\n----------------------------------"); - printf(" %s ", date); + printf("\n----------------------------------") + printf(" %s ", date) printf("----------------------------------\n") - date = $1; + date = $1 + nick = "" } { if ($3 ~ "<.*>" || $3 ~ "-!-") { - sub("<", "", $3); - sub(">", "", $3); + sub("<", "", $3) + sub(">", "", $3) if (nick != $3) { - printf("\n"); - printf("%s %10s ", $2, $3); - nick = $3; + printf("\n") + printf("%s %10s ", $2, $3) + nick = $3 } else { - printf("%s %10s ", $2, ""); + printf("%s %10s ", $2, "") } - sub("[^ ]* [^ ]* [^ ]* ", ""); + sub("[^ ]* [^ ]* [^ ]* ", "") } else { - printf("%s %10s ", $2, ""); - sub("[^ ]* [^ ]* ", ""); + printf("%s %10s ", $2, "") + sub("[^ ]* [^ ]* ", "") } - sub("^\001ACTION ", "~~ "); - sub("\001$", " ~~"); + sub("^\001ACTION ", "~~ ") + sub("\001$", " ~~") for (offset = 0; length($0) > 0; offset = 18) { - row = substr($0, 1, WIDTH); + row = substr($0, 1, WIDTH) if (length(row) >= WIDTH) - sub(" [^ ]*$", "", row); + sub(" [^ ]*$", "", row) - $0 = substr($0, length(row) + 1); - sub(" *", ""); + $0 = substr($0, length(row) + 1) + sub(" *", "") - printf("%" offset "s%s\n", "", row); + printf("%" offset "s%s\n", "", row) } - system("true || false"); + system("") }' diff --git a/ii/bin/ii-filter-sed b/ii/bin/ii-filter-sed @@ -1,61 +0,0 @@ -busybox awk ' - -BEGIN { - NICK_COL = 14; - TEXT_COL = 80 - NICK_COL - length(" "); -} - -/^$/ { - next; -} - -/==> .* <==/ { - sub("/out <==", ""); - sub("==> ", ""); - - print("\n" $0); - - next; -} - -{ - sub(/[0-9]*-[0-9]*-[0-9]* /, ""); - - date = $0; - sub(/ .*/, "", date); - sub(/^[^ ]* /, "", $0 ); - - if (match($0, /^[-=<#*@+]/)) { - nick = $0; - sub(/ .*/, "", nick); - sub(/^[^ ]* /, "", $0 ); - sub(/</, "", nick); - sub(/>/, "", nick); - } else { - nick = "-!-"; - } - - if (nick != lastnick) - printf("%-" NICK_COL "s|\n", date); - - printf("%" NICK_COL "s| ", - (nick != lastnick && nick != "-!-") ? nick : ""); - - for (first = 1; length($0) >= TEXT_COL; first = 0) { - line = substr($0, 1, TEXT_COL); - sub(/ [^ ]*$/, "", line); - $0 = substr($0, length(line) + 1); - - if (!first) - printf("%" NICK_COL "s| ", ""); - - print(line); - } - - if (!first) - printf("%" NICK_COL "s| ", ""); - - print($0); - - lastnick = nick; -}' "$@"