dot

packages and services management
Log | Files | Refs | README

commit 4a432ae16905e77f7fc52bdd09cd34ee0b957d8d
parent f27631a6ba94d7f3ecdedd4eefc7f256b11c2ae6
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Mon, 31 Jul 2017 09:14:28 +0200

scripts/bin/{tree,www-git}: fixed tree content

Both had an index issue ('<' -> '<='), and www-git had issue
for strings without separator.

Diffstat:
Mscripts/bin/tree | 4++--
Mscripts/bin/www-git | 11++++++-----
2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/scripts/bin/tree b/scripts/bin/tree @@ -3,7 +3,7 @@ awk '{ do { print } while (sub("/[^/]*$", "")) }' | sort -u | awk '{ count = split($0, line, "/") - for (i = 1; i < count; i++) { + for (i = 1; i <= count; i++) { lines[NR"]["0] = $0 lines[NR"]["i] = "| " prev[i] = line[i] @@ -13,7 +13,7 @@ awk '{ } END { for (i = 1; !stop; i++) { stop = tail = 1 - for (l = NR; l > 0; l--) { + for (l = NR - 1; l > 0; l--) { if (lines[l"]["i] == "| " && tail) { lines[l"]["i] = " " stop = 0 diff --git a/scripts/bin/www-git b/scripts/bin/www-git @@ -25,12 +25,12 @@ cd "git/$NAME" || exit 1 printf '%s\n' "$HEADER" - awk '{ + git -C "$1" ls-files | awk '{ gsub("&", "\&amp;"); gsub("<", "\&lt;") do { print } while (sub("/[^/]*$", "")) }' | sort -u | awk '{ count = split($0, line, "/") - for (i = 1; i < count; i++) { + for (i = 1; i <= count; i++) { lines[NR"]["0] = $0 lines[NR"]["i] = "| " prev[i] = line[i] @@ -40,7 +40,7 @@ cd "git/$NAME" || exit 1 } END { for (i = 1; !stop; i++) { stop = tail = 1 - for (l = NR; l > 0; l--) { + for (l = NR - 1; l > 0; l--) { if (lines[l"]["i] == "| " && tail) { lines[l"]["i] = " " stop = 0 @@ -58,8 +58,9 @@ cd "git/$NAME" || exit 1 for (l = 1; l < NR; l++) { for (i = 1; lines[l"]["i]; i++) printf "%s", lines[l"]["i] - sub(".*/", "<a href=\"" lines[l"]["0] "\">", lines[l"]["0]) - print lines[l"]["0] "</a>" + printf "<a href=\"file/%s\">", lines[l"]["0] + sub(".*/|^", "", lines[l"]["0]) + printf "%s</a>\n", lines[l"]["0] } }'