~acdw/tssg

2413faebe3a85f8432548e79c2046b7e97603ac6 — Case Duckworth 5 years ago 76bafa5
Use temp file for index
1 files changed, 6 insertions(+), 5 deletions(-)

M tssg.sh
M tssg.sh => tssg.sh +6 -5
@@ 1,8 1,9 @@
#!/bin/sh
I=./index.html;O="${1:-out}";H=hd.txt;F=ft.txt;mkdir -p $O;touch $H $F $I
alias eo='echo >>"$OF"' p=printf;po(){ cat $H "$1" >"$OF"; }
for f in ./*.html;do [ "$f" = $I ] || (OF="$O/$f";p "$f\t"
po "$f"; <$F >>"$OF";eo '<a id=ret href=.>return</a>';p OK\\n;) done
p "$I\t";OF="$O/$I";po "$I";eo '<ul id=toc>';for p in $O/*.html;do
alias eo='echo >>"$OF"' p=printf;po(){ cat $H "$@" $F >"$OF"; }
for f in ./*.html;do [ "$f" = $I ] || (OF="$O/$f";p "$f\t";
po "$f";eo "<a id=ret href=$I>return</a>";p OK\\n;) done
p $I\\t;OF="$O/$I~";eo '<ul id=toc>';for p in $O/*.html;do
[ -e "$p" ] && (t="$(sed -n 's,.*<title>\(.*\)</title>.*,\1,ip;T;q' "$p")"
eo "<li><a href='${p##*/}'>$t</a></li>";) done;eo "</ul>"; <$F >>"$OF";p OK\\n
eo "<li><a href='${p##*/}'>$t</a></li>";) done;eo "</ul>";OF="$O/$I";
po $I "$O/$I~";p OK\\n