From 9cbff995f6fcec9e91efda6baf2f896a1fc52772 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 3 Aug 2022 23:48:29 -0500 Subject: Make it like, work. --- ht.sh | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'ht.sh') diff --git a/ht.sh b/ht.sh index cc0d0ba..7f20255 100755 --- a/ht.sh +++ b/ht.sh @@ -7,17 +7,14 @@ header_file=header.htm footer_file=footer.htm meta_file=meta.sh -# state -HTDAT="$(date +%s)" -HT_TMPL_COUNT=0 - print() { printf '%s\n' "$*" } htt() { # htt FILE # Like `cat`, but with templating. - ht_end="ht_main_${HTDAT}_${HT_TMPL_COUNT}" # be extra double sure + : "${HT_TMPL_COUNT:=0}" + ht_end="ht_main_$(date +%s)_${HT_TMPL_COUNT}" # be extra double sure eval "$( print "cat <<$ht_end" cat "$@" @@ -40,23 +37,24 @@ htmeta_clear() { *) # other -- XXX: Don't know what to do ;; esac - done <"$meta_file" + done <"$meta_file" 2>/dev/null } htmeta() { # htmeta FILE # Collect metadata from FILE. # Metadata looks like this: `;;@` - sed -n 's/^;;@//p' "$1" | tee "$meta_file" + sed -n 's/^;;@//p' "$1" 2>/dev/null | tee "$meta_file" } main() { # Make two passes over each input file, collecting metadata and content. - : # Of course, this isn't safe, but you trust yourself, right? for file; do eval "$(htmeta_clear)" eval "$(htmeta "$file")" - - ./ht.awk <"$file" | htt "$header_file" - "$footer_file" >"${file}ml" + ./ht.awk <"$file" | htt "$header_file" - "$footer_file" done } + +test "$DEBUG" && set -x +test "$SOURCE" || main "$@" -- cgit 1.4.1-21-gabe81