dot

packages and services management
Log | Files | Refs | README

commit a7c6c43f71fc2a03360532fcc51e9821dfe3bdf8
parent 65a23b19c01c10a650fc2aa2000ee847043e519a
Author: Josuah Demangeon <mail@josuah.net>
Date:   Thu, 13 Dec 2018 23:22:27 +0100

bin/ltree: use a tab to separate info from paths

Diffstat:
Mbin/ltree | 26+++++++++++++++-----------
Mbin/pack-ftp | 1+
2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/bin/ltree b/bin/ltree @@ -18,6 +18,7 @@ BEGIN { NODE = "├─ "; TAIL = "└─ "; VOID = " "; + FS = "\t"; if (ARGV[1] == "-h") { HTML = ARGV[2]; @@ -45,17 +46,19 @@ BEGIN { # [ 1:[ 1:LINE, 2:LINE, 3:LINE, 4:LINE, 5:NODE, 6:"filename" ] ] { - sub(" \\.$", "", $0); - sub(" -> .*", "", $0); - infos = $0; - sub(" \\./.*", "", infos); - sub(".* \\./", "", $0); - LIST[NR"path"] = $0; - count = split($0, paths, "/"); + if (HTML) { + gsub("&", "\\&amp;", $0); + gsub("<", "\\&lt;", $0); + gsub(">", "\\&gt;", $0); + gsub("\"", "\\&quote;", $0); + } + + count = split($2, paths, "/"); for (i = 2; i < count; i++) LIST[NR":"i] = LINE; + LIST[NR"path"] = $2; LIST[NR":"count] = NODE; - LIST[NR":"1] = infos " "; + LIST[NR":"1] = $1 " "; LIST[NR"name"] = paths[count]; } @@ -80,8 +83,9 @@ END { } for (nr = 1; nr <= NR; nr++) { - for (nf = 1; LIST[nr":"nf] != ""; nf++) printf("%s", LIST[nr":"nf]); - if (!HTML) print(LIST[nr"name"]); - else print("<a href=\"" HTML "/" LIST[nr"path"] "\">" LIST[nr"name"] "</a>"); + for (nf = 1; LIST[nr":"nf] != ""; nf++) printf "%s", LIST[nr":"nf]; + if (HTML) { + print "<a href=\"" HTML "/" LIST[nr"path"] "\">" LIST[nr"name"] "</a>"; + } else print LIST[nr"name"]; } } diff --git a/bin/pack-ftp b/bin/pack-ftp @@ -4,6 +4,7 @@ pack=$1 version=${2:-$(sed q "/etc/pack/$1/version")} url=$3 trap "rm -f '$PACK/tar/$pack/$version.tar'" INT TERM EXIT +mkdir -p "$PACK/src/$pack/$version" "$PACK/tar/$pack" wget -O- "$url" | pack-extract "$url" >$PACK/tar/$pack/$version.tar trap - INT TERM EXIT