DKL9 GitList
Repositories
DKL9 home
site_root
Code
Commits
Branches
Tags
Search
Tree:
993e20c
Branches
Tags
master
site_root
scripts
script_page.sh
Initial commit: track much site content
dkl9
commited
993e20c
at 2025-352 15:27:28
script_page.sh
Blame
History
Raw
#!/bin/sh # script_page - generate a webpage documenting a script # usage: script_page script # Fills in fields in template.html, assumed to be in the working directory. # # Changelog: # 2023-236 initial development # 2023-246 exit on error # 2025-182 fix newlines and backslashes # # https://dkl9.net/scripts/script_page.html if [ -z "$1" ] || ! [ -f "$1" ] then echo "${0}: expected script filename" exit 1 fi SCRIPT_NAME="${1%.*}" SUFFIX="${1##*.}" PURPOSE=`sed '2 s/^.* - //; 2 p; d' <"$1"` USAGE=`sed '3 s/^\(#\|--\) usage: //; 3 p; d' <"$1"` DESC=`sed '/^\(#\|--\)$/,$ d; 1,3 d; s/^\(#\|--\) //' <"$1"` CHLOG=`sed '1,/^\(#\|--\) Changelog:$/ d; /^\(#\|--\)$/,$ d; s/^\(#\|--\) //; s/^/<br>/' <"$1"` SRC=`sed '1,/^$/ d' <"$1"` PAGE_NAME="${SCRIPT_NAME}.html" cp template.html "$PAGE_NAME" BELL=`printf '\x07'` bs() { for I in $(seq "$1") do printf '\' done } sub() { RV=`printf '%s' "$2" | paste -sd "${BELL}"` RV=`printf '%s\n' "$RV" | sed "s/$(bs 2)\\(.\\)/$(bs 4)\\1/g; s/${BELL}/$(bs 2)n/g"` SC="s${BELL}\$$1${BELL}$RV${BELL}g" sed -i "$SC" "$PAGE_NAME" } sub script_name "$SCRIPT_NAME" sub suffix "$SUFFIX" sub purpose "$PURPOSE" sub usage "$USAGE" sub description "$DESC" sub changelog "$CHLOG" sub source "$SRC"