use yet even more bin/jval-wrapper.sh instead of direct grep of JSON files
We use the `bin/jval-wrapper.sh` tool to obtain information from JSON files instead of attempting using a "GROSS HACK" that involved using `grep(1)` (and friends) as those "GROSS HACK"s assumed that the layout of the JSON was canonical. The `bin/jval-wrapper.sh` tool is able to deal with various layouts of JSON including non-canonical layouts. Moreover, by using the `bin/jval-wrapper.sh` tool we greatly reduce the places in bin tools that contain "GROSS HACK"s. Adjusted `bin/gen-status.sh` to use `bin/jval-wrapper.sh`. Changed `bin/gen-status.sh` VERSION from "1.5.8 2024-08-05" to "1.6 2024-08-17". Performed `make gen_status` to test the above under macOS. Adjusted `bin/gen-years.sh` to use `bin/jval-wrapper.sh`. Changed `bin/gen-years.sh` VERSION from "1.3.7 2024-08-05" to "1.4 2024-08-17". Performed `make gen_years` to test the above under macOS. Adjusted `bin/output-index-author.sh` to use `bin/jval-wrapper.sh`. Changed `bin/output-index-author.sh` VERSION from "1.7.3 2024-08-05" to "1.8 2024-08-17". Performed `make entry_index` to test the above under macOS. Added `make quick_year_index` to generate year level index.html files when year level `YYYY/README.md` is newer. The `make quick_www` calls `quick_year_index` instead of `make gen_year_index`. The `bin` directory is now sat as `BIN_PATH=$TOPDIR/bin`, where `$TOPDIR` is determined by top of the git repo (as determined by the command: `git rev-parse --is-inside-work-tree`) and potentially modified by `-d topdir`. After `cd $TOPDIR`, we set `BIN_DIR=bin`. All tools from this repo are now assumed to under "$BIN_DIR". Removed command like options such as `-T md2html.sh`, and `-p tool` that used to be able to change the location of a `bin` tool. Changed `bin/gen-authors.sh` VERSION from "1.11 2024-08-13" to "1.12 2024-08-18". Changed `bin/gen-location.sh` VERSION from "1.5 2024-08-17" to "1.6 2024-08-18". Changed `bin/readme2index.sh` VERSION from "1.2.7 2024-08-05" to "1.3 2024-08-17". Modified `bin/all-run.sh` to use the `bin` directory mechanism. Modified `bin/all-years.sh` to use the `bin` directory mechanism. Modified `bin/gen-other-html.sh` to use the `bin` directory mechanism. Modified `bin/gen-year-index.sh` to use the `bin` directory mechanism. Modified `bin/md2html.sh` to use the `bin` directory mechanism. Modified `bin/quick-readme2index.sh` to use the `bin` directory mechanism. Modified `bin/readme2index.sh` to use the `bin` directory mechanism. Changed `bin/all-run.sh` VERSION from "1.3.6 2024-08-05" to "1.4 2024-08-17". Changed `bin/all-years.sh` VERSION from "1.0.5 2024-08-05" to "1.1 2024-08-17". Changed `bin/gen-other-html.sh` VERSION from "1.3 2024-08-11" to "1.4 2024-08-17". Changed `bin/gen-year-index.sh` VERSION from "1.1.2 2024-08-05" to "1.2 2024-08-17". Changed `bin/quick-readme2index.sh` VERSION from "1.1.7 2024-08-05" to "1.2 2024-08-17". Changed `bin/md2html.sh` VERSION from "1.5.5 2024-08-05" to "1.6 2024-08-17". Added some whitespace in the form of empty lines to tools. Made checks for tools under `bin` directory more consistent. When using `-Q` (quick mode) and the prerequisite files are newer, we force the target to be touched so that a later run will not have to build the target HTML file. Performed `make quick_www` to test the above under macOS. Performed `make www` to test the above under macOS.
This commit is contained in:
1 parent
f159369a0a
commit
0e5864b8b0
39 files changed
+1694
-795
No files matched your search
@@ -303,7 +303,7 @@ indent.c:
|
||||
.PHONY: help genpath genfilelist verify_entry_files gen_authors quick_authors \
|
||||
gen_location quick_location gen_years find_missing_links test entry_index gen_top_html \
|
||||
thanks gen_other_html quick_other_html quick_entry_index \
|
||||
gen_year_index quick_www www untar_entry_tarball untar_year_tarball \
|
||||
gen_year_index quick_year_index quick_www www untar_entry_tarball untar_year_tarball \
|
||||
form_entry_tarball form_year_tarball tar gen_status gen_sitemap \
|
||||
sitemap timestamp update csv2entry entry2csv
|
||||
|
||||
@@ -344,6 +344,7 @@ help:
|
||||
@echo 'make gen_other_html ;: build entry HTML files from markdown other than README.md'
|
||||
@echo 'make quick_other_html ;: build entry non-index.html files that might be out of date'
|
||||
@echo 'make gen_year_index ;: generate year level index.html files using from README.md files'
|
||||
@echo 'make quick_year_index ;: generate year level index.html when year level README.md is newer'
|
||||
@echo 'make gen_top_html ;: generate a number of the top level HTML files from markdown'
|
||||
@echo 'make gen_next ;: generate the HTML files in next/'
|
||||
@echo 'make quick_entry_index ;: build winner index.html files that might be out of date'
|
||||
@@ -551,6 +552,16 @@ gen_year_index: ${ALL_YEARS} ${GEN_YEAR_INDEX}
|
||||
${ALL_YEARS} -v 1 ${GEN_YEAR_INDEX} -v 1
|
||||
@echo '=-=-=-=-= IOCCC complete make $@ =-=-=-=-='
|
||||
|
||||
# generate year level index.html files when year level README.md is newer
|
||||
#
|
||||
# generate year level index.html files using the
|
||||
# ${GEN_YEAR_INDEX} tool (bin/gen-year-index.sh).
|
||||
#
|
||||
quick_year_index: ${ALL_YEARS} ${GEN_YEAR_INDEX}
|
||||
@echo '=-=-=-=-= IOCCC begin make $@ =-=-=-=-='
|
||||
${ALL_YEARS} -v 1 -Q ${GEN_YEAR_INDEX} -v 1
|
||||
@echo '=-=-=-=-= IOCCC complete make $@ =-=-=-=-='
|
||||
|
||||
# build winner index.html files that might be out of date
|
||||
#
|
||||
# This rule uses the ${QUICK_README2INDEX} tool
|
||||
@@ -690,7 +701,7 @@ quick_www:
|
||||
${MAKE} quick_authors
|
||||
${MAKE} quick_location
|
||||
${MAKE} gen_years
|
||||
${MAKE} gen_year_index
|
||||
${MAKE} quick_year_index
|
||||
${MAKE} gen_top_html
|
||||
${MAKE} quick_entry_index
|
||||
${MAKE} quick_other_html
|
||||
|
||||
+65
-22
@@ -17,7 +17,7 @@
|
||||
#
|
||||
# Each tool run with command line of the form:
|
||||
#
|
||||
# tool [any -D, -t tagline, -T md2html.sh, -p tool, -w site_url] [more_options] YYYY/dir
|
||||
# tool [any -D, -t tagline, -w site_url] [more_options] YYYY/dir
|
||||
#
|
||||
# For example:
|
||||
#
|
||||
@@ -55,6 +55,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -111,9 +112,10 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.3.6 2024-08-05"
|
||||
export VERSION="1.4 2024-08-17"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -131,8 +133,6 @@ fi
|
||||
export TOPDIR
|
||||
export DOCROOT_SLASH="../../"
|
||||
export TAGLINE="unspecified"
|
||||
export MD2HTML_SH="bin/md2html.sh"
|
||||
export PANDOC_WRAPPER="bin/pandoc-wrapper.sh"
|
||||
export REPO_TOP_URL="https://github.com/ioccc-src/temp-test-ioccc"
|
||||
# GitHub puts individual files under the "blob/master" sub-directory.
|
||||
export REPO_URL="$REPO_TOP_URL/blob/master"
|
||||
@@ -142,15 +142,17 @@ export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
export EXIT_CODE="0"
|
||||
|
||||
|
||||
# clear options we will add to tools
|
||||
#
|
||||
unset TOOL_OPTION
|
||||
declare -ag TOOL_OPTION
|
||||
|
||||
|
||||
# usage
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
[-t tagline] [-T md2html.sh] [-p tool] [-w site_url]
|
||||
[-t tagline] [-w site_url]
|
||||
tool [more_options]
|
||||
|
||||
-h print help message and exit
|
||||
@@ -167,10 +169,6 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
|
||||
-t tagline string to write about the tool that formed the markdown content (def: $TAGLINE)
|
||||
NOTE: The '-t tagline' is passed as leading options on tool command lines.
|
||||
-T md2html.sh run 'markdown to html tool' to convert markdown into HTML (def: $MD2HTML_SH)
|
||||
NOTE: The '-T md2html.sh' is passed as leading options on tool command lines.
|
||||
|
||||
-p tool run 'pandoc wrapper tool' (not pandoc path) during HTML phase number 21 (def: use $PANDOC_WRAPPER)
|
||||
|
||||
-w site_url Base URL of the website (def: $SITE_URL)
|
||||
NOTE: The '-w site_url' is passed as leading options on tool command lines.
|
||||
@@ -178,7 +176,7 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
tool the tool to run over all entries
|
||||
[more_options] additional tool command line options to use before the YYYY/dir argument
|
||||
|
||||
NOTE: Any '-D docroot/', '-t tagline', '-T md2html.sh', '-p tool', '-w site_url'
|
||||
NOTE: Any '-D docroot/', '-t tagline', '-w site_url'
|
||||
are passed to the 'tool' at the beginning of the command line, and
|
||||
before any optional 'more_options' and before the final YYYY/dir argument.
|
||||
|
||||
@@ -195,9 +193,10 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNt:T:p:w: flag; do
|
||||
while getopts :hv:Vd:D:nNt:w: flag; do
|
||||
case "$flag" in
|
||||
h) echo "$USAGE" 1>&2
|
||||
exit 2
|
||||
@@ -246,14 +245,6 @@ while getopts :hv:Vd:D:nNt:T:p:w: flag; do
|
||||
TOOL_OPTION+=("-t")
|
||||
TOOL_OPTION+=("$TAGLINE")
|
||||
;;
|
||||
T) MD2HTML_SH="$OPTARG"
|
||||
TOOL_OPTION+=("-T")
|
||||
TOOL_OPTION+=("$MD2HTML_SH")
|
||||
;;
|
||||
p) PANDOC_WRAPPER="$OPTARG"
|
||||
TOOL_OPTION+=("-p")
|
||||
TOOL_OPTION+=("$PANDOC_WRAPPER")
|
||||
;;
|
||||
w) SITE_URL="$OPTARG"
|
||||
TOOL_OPTION+=("-w")
|
||||
TOOL_OPTION+=("$SITE_URL")
|
||||
@@ -275,7 +266,7 @@ while getopts :hv:Vd:D:nNt:T:p:w: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# remove the options
|
||||
#
|
||||
shift $(( OPTIND - 1 ));
|
||||
@@ -303,6 +294,7 @@ case "$#" in
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -323,6 +315,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -346,6 +339,51 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
if [[ ! -d $BIN_PATH ]]; then
|
||||
echo "$0: ERROR: bin is not a directory under topdir: $BIN_PATH" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
|
||||
# verify that the bin/md2html.sh tool is executable
|
||||
#
|
||||
export MD2HTML_SH="$BIN_DIR/md2html.sh"
|
||||
if [[ ! -e $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh does not exist: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not a regular file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not an executable file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that the bin/pandoc-wrapper.sh tool is executable
|
||||
#
|
||||
export PANDOC_WRAPPER="$BIN_DIR/pandoc-wrapper.sh"
|
||||
if [[ ! -e $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh does not exist: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not a regular file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not an executable file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify we have a non-empty readable .top file
|
||||
#
|
||||
export TOP_FILE=".top"
|
||||
@@ -408,8 +446,6 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: TOPDIR=$TOPDIR" 1>&2
|
||||
echo "$0: debug[3]: DOCROOT_SLASH=$DOCROOT_SLASH" 1>&2
|
||||
echo "$0: debug[3]: TAGLINE=$TAGLINE" 1>&2
|
||||
echo "$0: debug[3]: MD2HTML_SH=$MD2HTML_SH" 1>&2
|
||||
echo "$0: debug[3]: PANDOC_WRAPPER=$PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: REPO_TOP_URL=$REPO_TOP_URL" 1>&2
|
||||
echo "$0: debug[3]: REPO_URL=$REPO_URL" 1>&2
|
||||
echo "$0: debug[3]: SITE_URL=$SITE_URL" 1>&2
|
||||
@@ -422,9 +458,14 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: TOOL=$TOOL" 1>&2
|
||||
echo "$0: debug[3]: REPO_NAME=$REPO_NAME" 1>&2
|
||||
echo "$0: debug[3]: CD_FAILED=$CD_FAILED" 1>&2
|
||||
echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2
|
||||
echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2
|
||||
echo "$0: debug[3]: MD2HTML_SH=$MD2HTML_SH" 1>&2
|
||||
echo "$0: debug[3]: PANDOC_WRAPPER=$PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: TOP_FILE=$TOP_FILE" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# -N stops early before any processing is performed
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -434,6 +475,7 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# process each year
|
||||
#
|
||||
export YYYY
|
||||
@@ -620,6 +662,7 @@ for YYYY in $(< "$TOP_FILE"); do
|
||||
done
|
||||
done
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
if [[ $EXIT_CODE -ne 0 ]]; then
|
||||
|
||||
+74
-36
@@ -16,7 +16,7 @@
|
||||
#
|
||||
# Each tool run with command line of the form:
|
||||
#
|
||||
# tool [any -D, -t tagline, -T md2html.sh, -p tool, -w site_url] [more_options] YYYY
|
||||
# tool [any -D, -t tagline, -w site_url] [more_options] YYYY
|
||||
#
|
||||
# For example:
|
||||
#
|
||||
@@ -54,6 +54,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -97,6 +98,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -109,9 +111,10 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.0.5 2024-08-05"
|
||||
export VERSION="1.1 2024-08-17"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -129,8 +132,6 @@ fi
|
||||
export TOPDIR
|
||||
export DOCROOT_SLASH="../../"
|
||||
export TAGLINE="unspecified"
|
||||
export MD2HTML_SH="bin/md2html.sh"
|
||||
export PANDOC_WRAPPER="bin/pandoc-wrapper.sh"
|
||||
export REPO_TOP_URL="https://github.com/ioccc-src/temp-test-ioccc"
|
||||
# GitHub puts individual files under the "blob/master" sub-directory.
|
||||
export REPO_URL="$REPO_TOP_URL/blob/master"
|
||||
@@ -138,17 +139,20 @@ export SITE_URL="https://ioccc-src.github.io/temp-test-ioccc"
|
||||
#
|
||||
export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
export QUICK_MODE=
|
||||
export EXIT_CODE="0"
|
||||
|
||||
|
||||
# clear options we will add to tools
|
||||
#
|
||||
unset TOOL_OPTION
|
||||
declare -ag TOOL_OPTION
|
||||
|
||||
|
||||
# usage
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
[-t tagline] [-T md2html.sh] [-p tool] [-w site_url]
|
||||
[-Q] [-t tagline] [-w site_url]
|
||||
tool [more_options]
|
||||
|
||||
-h print help message and exit
|
||||
@@ -164,12 +168,10 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
-n go thru the actions, but do not update any files (def: do the action)
|
||||
-N do not process anything, just parse arguments (def: process something)
|
||||
|
||||
-Q quick mode, do not run $MD2HTML_SH unless markdown is out of date (def: do)
|
||||
|
||||
-t tagline string to write about the tool that formed the markdown content (def: $TAGLINE)
|
||||
NOTE: The '-t tagline' is passed as leading options on tool command lines.
|
||||
-T md2html.sh run 'markdown to html tool' to convert markdown into HTML (def: $MD2HTML_SH)
|
||||
NOTE: The '-T md2html.sh' is passed as leading options on tool command lines.
|
||||
|
||||
-p tool run 'pandoc wrapper tool' (not pandoc path) during HTML phase number 21 (def: use $PANDOC_WRAPPER)
|
||||
|
||||
-w site_url Base URL of the website (def: $SITE_URL)
|
||||
NOTE: The '-w site_url' is passed as leading options on tool command lines.
|
||||
@@ -177,7 +179,7 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
tool the tool to run over all entries
|
||||
[more_options] additional tool command line options to use before the YYYY/dir argument
|
||||
|
||||
NOTE: Any '-t tagline', '-T md2html.sh', '-p tool', '-w site_url'
|
||||
NOTE: Any '-Q', '-t tagline', '-w site_url'
|
||||
are passed to the 'tool' at the beginning of the command line, and
|
||||
before any optional 'more_options' and before the final YYYY/dir argument.
|
||||
|
||||
@@ -194,9 +196,10 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNt:T:p:w: flag; do
|
||||
while getopts :hv:Vd:D:nNQt:w: flag; do
|
||||
case "$flag" in
|
||||
h) echo "$USAGE" 1>&2
|
||||
exit 2
|
||||
@@ -225,6 +228,9 @@ while getopts :hv:Vd:D:nNt:T:p:w: flag; do
|
||||
;;
|
||||
N) DO_NOT_PROCESS="-N"
|
||||
;;
|
||||
Q) QUICK_MODE="-Q"
|
||||
TOOL_OPTION+=("-Q")
|
||||
;;
|
||||
t) # parse -t tagline
|
||||
case "$OPTARG" in
|
||||
*"'"*)
|
||||
@@ -245,14 +251,6 @@ while getopts :hv:Vd:D:nNt:T:p:w: flag; do
|
||||
TOOL_OPTION+=("-t")
|
||||
TOOL_OPTION+=("$TAGLINE")
|
||||
;;
|
||||
T) MD2HTML_SH="$OPTARG"
|
||||
TOOL_OPTION+=("-T")
|
||||
TOOL_OPTION+=("$MD2HTML_SH")
|
||||
;;
|
||||
p) PANDOC_WRAPPER="$OPTARG"
|
||||
TOOL_OPTION+=("-p")
|
||||
TOOL_OPTION+=("$PANDOC_WRAPPER")
|
||||
;;
|
||||
w) SITE_URL="$OPTARG"
|
||||
TOOL_OPTION+=("-w")
|
||||
TOOL_OPTION+=("$SITE_URL")
|
||||
@@ -274,7 +272,7 @@ while getopts :hv:Vd:D:nNt:T:p:w: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# remove the options
|
||||
#
|
||||
shift $(( OPTIND - 1 ));
|
||||
@@ -302,6 +300,7 @@ case "$#" in
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -322,6 +321,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -345,6 +345,51 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
if [[ ! -d $BIN_PATH ]]; then
|
||||
echo "$0: ERROR: bin is not a directory under topdir: $BIN_PATH" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
|
||||
# verify that the bin/md2html.sh tool is executable
|
||||
#
|
||||
export MD2HTML_SH="$BIN_DIR/md2html.sh"
|
||||
if [[ ! -e $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh does not exist: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not a regular file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not an executable file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that the bin/pandoc-wrapper.sh tool is executable
|
||||
#
|
||||
export PANDOC_WRAPPER="$BIN_DIR/pandoc-wrapper.sh"
|
||||
if [[ ! -e $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh does not exist: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not a regular file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not an executable file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify we have a non-empty readable .top file
|
||||
#
|
||||
export TOP_FILE=".top"
|
||||
@@ -365,6 +410,7 @@ if [[ ! -s $TOP_FILE ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# verify tool is executable
|
||||
#
|
||||
if [[ ! -e $TOOL ]]; then
|
||||
@@ -380,20 +426,6 @@ if [[ ! -x $TOOL ]]; then
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# verify that the md2html.sh is an executable file
|
||||
#
|
||||
if [[ ! -e $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: md2html.sh does not exist: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: md2html.sh is not a regular file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: md2html.sh is not an executable file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# print running info if verbose
|
||||
#
|
||||
@@ -407,13 +439,12 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: TOPDIR=$TOPDIR" 1>&2
|
||||
echo "$0: debug[3]: DOCROOT_SLASH=$DOCROOT_SLASH" 1>&2
|
||||
echo "$0: debug[3]: TAGLINE=$TAGLINE" 1>&2
|
||||
echo "$0: debug[3]: MD2HTML_SH=$MD2HTML_SH" 1>&2
|
||||
echo "$0: debug[3]: PANDOC_WRAPPER=$PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: REPO_TOP_URL=$REPO_TOP_URL" 1>&2
|
||||
echo "$0: debug[3]: REPO_URL=$REPO_URL" 1>&2
|
||||
echo "$0: debug[3]: SITE_URL=$SITE_URL" 1>&2
|
||||
echo "$0: debug[3]: NOOP=$NOOP" 1>&2
|
||||
echo "$0: debug[3]: DO_NOT_PROCESS=$DO_NOT_PROCESS" 1>&2
|
||||
echo "$0: debug[3]: QUICK_MODE=$QUICK_MODE" 1>&2
|
||||
echo "$0: debug[3]: EXIT_CODE=$EXIT_CODE" 1>&2
|
||||
for index in "${!TOOL_OPTION[@]}"; do
|
||||
echo "$0: debug[3]: TOOL_OPTION[$index]=${TOOL_OPTION[$index]}" 1>&2
|
||||
@@ -421,9 +452,14 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: TOOL=$TOOL" 1>&2
|
||||
echo "$0: debug[3]: REPO_NAME=$REPO_NAME" 1>&2
|
||||
echo "$0: debug[3]: CD_FAILED=$CD_FAILED" 1>&2
|
||||
echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2
|
||||
echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2
|
||||
echo "$0: debug[3]: MD2HTML_SH=$MD2HTML_SH" 1>&2
|
||||
echo "$0: debug[3]: PANDOC_WRAPPER=$PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: TOP_FILE=$TOP_FILE" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# -N stops early before any processing is performed
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -433,6 +469,7 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# process each year
|
||||
#
|
||||
export YYYY
|
||||
@@ -515,6 +552,7 @@ for YYYY in $(< "$TOP_FILE"); do
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
if [[ $EXIT_CODE -ne 0 ]]; then
|
||||
|
||||
+42
-27
@@ -28,6 +28,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -71,6 +72,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -83,6 +85,7 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.1.10 2024-08-05"
|
||||
@@ -105,10 +108,10 @@ export REPO_TOP_URL="https://github.com/ioccc-src/temp-test-ioccc"
|
||||
# GitHub puts individual files under the "blob/master" sub-directory.
|
||||
export REPO_URL="$REPO_TOP_URL/blob/master"
|
||||
|
||||
|
||||
# set usage message
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
[-p tool] [-w site_url]
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N] [-w site_url]
|
||||
YYYY/dir
|
||||
|
||||
-h print help message and exit
|
||||
@@ -121,8 +124,6 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
-n go thru the actions, but do not update any files (def: do the action)
|
||||
-N do not process file, just parse arguments and ignore the file (def: process the file)
|
||||
|
||||
-p tool This option is ignored
|
||||
|
||||
-w site_url This option is ignored
|
||||
|
||||
YYYY/dir path from topdir to entry directory: must contain the files: README.md, .path and .entry.json
|
||||
@@ -140,15 +141,17 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# setup
|
||||
#
|
||||
export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
export EXIT_CODE="0"
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNp:U:w: flag; do
|
||||
while getopts :hv:Vd:D:nNU:w: flag; do
|
||||
case "$flag" in
|
||||
h) echo "$USAGE" 1>&2
|
||||
exit 2
|
||||
@@ -165,7 +168,6 @@ while getopts :hv:Vd:D:nNp:U:w: flag; do
|
||||
;;
|
||||
N) DO_NOT_PROCESS="-N"
|
||||
;;
|
||||
p) ;;
|
||||
U) ;;
|
||||
w) ;;
|
||||
\?) echo "$0: ERROR: invalid option: -$OPTARG" 1>&2
|
||||
@@ -185,7 +187,7 @@ while getopts :hv:Vd:D:nNp:U:w: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# parse the command line arguments
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -204,6 +206,7 @@ fi
|
||||
#
|
||||
export ENTRY_PATH="$1"
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -224,6 +227,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -247,6 +251,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
@@ -256,6 +261,28 @@ if [[ ! -d $BIN_PATH ]]; then
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
|
||||
# verify we have our awk tool
|
||||
#
|
||||
export FILELIST_ENTRY_JSON_AWK="$BIN_DIR/filelist.entry.json.awk"
|
||||
if [[ ! -e $FILELIST_ENTRY_JSON_AWK ]]; then
|
||||
echo "$0: ERROR: filelist.entry.json.awk does not exist: $FILELIST_ENTRY_JSON_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $FILELIST_ENTRY_JSON_AWK ]]; then
|
||||
echo "$0: ERROR: filelist.entry.json.awk is not a file: $FILELIST_ENTRY_JSON_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -r $FILELIST_ENTRY_JSON_AWK ]]; then
|
||||
echo "$0: ERROR: filelist.entry.json.awk is not a readable file: $FILELIST_ENTRY_JSON_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -s $FILELIST_ENTRY_JSON_AWK ]]; then
|
||||
echo "$0: ERROR: filelist.entry.json.awk is not a not a non-empty readable file: $FILELIST_ENTRY_JSON_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that ENTRY_PATH is a entry directory
|
||||
#
|
||||
if [[ ! -d $ENTRY_PATH ]]; then
|
||||
@@ -329,25 +356,6 @@ if [[ ! -r $ENTRY_JSON ]]; then
|
||||
exit 7
|
||||
fi
|
||||
|
||||
# verify we have our awk tool
|
||||
#
|
||||
export FILELIST_ENTRY_JSON_AWK="$BIN_DIR/filelist.entry.json.awk"
|
||||
if [[ ! -e $FILELIST_ENTRY_JSON_AWK ]]; then
|
||||
echo "$0: ERROR: filelist.entry.json.awk does not exist: $FILELIST_ENTRY_JSON_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $FILELIST_ENTRY_JSON_AWK ]]; then
|
||||
echo "$0: ERROR: filelist.entry.json.awk is not a file: $FILELIST_ENTRY_JSON_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -r $FILELIST_ENTRY_JSON_AWK ]]; then
|
||||
echo "$0: ERROR: filelist.entry.json.awk is not a readable file: $FILELIST_ENTRY_JSON_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -s $FILELIST_ENTRY_JSON_AWK ]]; then
|
||||
echo "$0: ERROR: filelist.entry.json.awk is not a not a non-empty readable file: $FILELIST_ENTRY_JSON_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# parameter debugging
|
||||
#
|
||||
@@ -367,6 +375,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: CD_FAILED=$CD_FAILED" 1>&2
|
||||
echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2
|
||||
echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2
|
||||
echo "$0: debug[3]: FILELIST_ENTRY_JSON_AWK=$FILELIST_ENTRY_JSON_AWK" 1>&2
|
||||
echo "$0: debug[3]: YEAR_DIR=$YEAR_DIR" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_DIR=$ENTRY_DIR" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_ID=$ENTRY_ID" 1>&2
|
||||
@@ -375,9 +384,9 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: DOT_PATH=$DOT_PATH" 1>&2
|
||||
echo "$0: debug[3]: DOT_PATH_CONTENT=$DOT_PATH_CONTENT" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_JSON=$ENTRY_JSON" 1>&2
|
||||
echo "$0: debug[3]: FILELIST_ENTRY_JSON_AWK=$FILELIST_ENTRY_JSON_AWK" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# If -N, time to exit
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -387,6 +396,7 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary file manifest list
|
||||
#
|
||||
export TMP_MANIFEST_LIST=".tmp.$NAME.MANIFEST_LIST.$$.tmp"
|
||||
@@ -409,6 +419,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary file manifest list is not used: $TMP_MANIFEST_LIST" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary find files list
|
||||
#
|
||||
export TMP_FILE_LIST=".tmp.$NAME.FILE_LIST.$$.tmp"
|
||||
@@ -431,6 +442,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary file manifest list is not used: $TMP_FILE_LIST" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# generate sorted list of entry files from the entry's manifest
|
||||
#
|
||||
# We also add ioccc.css and var.mk from the top level.
|
||||
@@ -448,6 +460,7 @@ if [[ $status -ne 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# generate sorted list of found entry files
|
||||
#
|
||||
# We also add ioccc.css and var.mk from the top level.
|
||||
@@ -470,6 +483,7 @@ if [[ $status -ne 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# note if the manifest does NOT match the file list
|
||||
#
|
||||
if [[ $V_FLAG -ge 5 ]]; then
|
||||
@@ -495,6 +509,7 @@ else
|
||||
EXIT_CODE=1 # exit 1
|
||||
fi
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
|
||||
+12
-5
@@ -360,8 +360,7 @@ while getopts :hv:Vd:D:nNj: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
#
|
||||
# remove the options
|
||||
#
|
||||
shift $(( OPTIND - 1 ));
|
||||
@@ -489,11 +488,19 @@ fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
|
||||
# find the jval-wrapper.sh tool
|
||||
# verify that the bin/jval-wrapper.sh tool is executable
|
||||
#
|
||||
JVAL_WRAPPER="$BIN_PATH/jval-wrapper.sh"
|
||||
JVAL_WRAPPER="$BIN_DIR/jval-wrapper.sh"
|
||||
if [[ ! -e $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh does not exist: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh is not a regular file: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: cannot find the bin/jval-wrapper.sh executable" 1>&2
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh is not an executable file: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
+33
-25
@@ -43,6 +43,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -161,6 +162,7 @@ unset TAR_FILE_SET
|
||||
declare -ag TAR_FILE_SET
|
||||
export TARBALL_DIR="/var/tmp"
|
||||
|
||||
|
||||
# usage
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir]
|
||||
@@ -402,7 +404,6 @@ function manifest_entry
|
||||
}
|
||||
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:c:s:i:T:nN flag; do
|
||||
@@ -446,7 +447,7 @@ while getopts :hv:Vd:c:s:i:T:nN flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# remove the options
|
||||
#
|
||||
shift $(( OPTIND - 1 ));
|
||||
@@ -465,6 +466,7 @@ if [[ $# -ne 1 ]]; then
|
||||
fi
|
||||
export ENTRY_PATH="$1"
|
||||
|
||||
|
||||
# if -i input_data, replace stdin with the input data file
|
||||
#
|
||||
if [[ -n $INPUT_DATA_FILE ]]; then
|
||||
@@ -561,32 +563,38 @@ if [[ ! -d $BIN_PATH ]]; then
|
||||
exit 6
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
|
||||
# verify that the bin/md2html.sh tool is executable
|
||||
#
|
||||
export JVAL_WRAPPER="$BIN_DIR/jval-wrapper.sh"
|
||||
export MD2HTML_SH="$BIN_DIR/md2html.sh"
|
||||
if [[ ! -e $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh does not exist: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not a regular file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not an executable file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that the bin/jval-wrapper.sh tool is executable
|
||||
#
|
||||
JVAL_WRAPPER="$BIN_DIR/jval-wrapper.sh"
|
||||
if [[ ! -e $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh file does not exist: $JVAL_WRAPPER" 1>&2
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh does not exist: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh is not a file: $JVAL_WRAPPER" 1>&2
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh is not a regular file: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: cannot find an executable bin/jval-wrapper.sh tool: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
#
|
||||
export MD2HTML="$BIN_DIR/md2html.sh"
|
||||
if [[ ! -e $MD2HTML ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh file does not exist: $MD2HTML" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $MD2HTML ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not a file: $MD2HTML" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $MD2HTML ]]; then
|
||||
echo "$0: ERROR: cannot find an executable bin/md2html.sh tool: $MD2HTML" 1>&2
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh is not an executable file: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
@@ -684,7 +692,7 @@ done
|
||||
|
||||
# determine TARBALL filename
|
||||
#
|
||||
NOW=$(/bin/date '+%Y%m%d.%H%M%S')
|
||||
NOW=$(date '+%Y%m%d.%H%M%S')
|
||||
export NOW
|
||||
export TARBALL="$TARBALL_DIR/$ENTRY_ID.mods.$NOW.tar.bz2"
|
||||
|
||||
@@ -718,7 +726,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2
|
||||
echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2
|
||||
echo "$0: debug[3]: JVAL_WRAPPER=$JVAL_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: MD2HTML=$MD2HTML" 1>&2
|
||||
echo "$0: debug[3]: MD2HTML_SH=$MD2HTML_SH" 1>&2
|
||||
echo "$0: debug[3]: YEAR_DIR=$YEAR_DIR" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_DIR=$ENTRY_DIR" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_ID=$ENTRY_ID" 1>&2
|
||||
@@ -1521,12 +1529,12 @@ if [[ -z $NOOP ]]; then
|
||||
if [[ ! -f $INDEX_HTML ]]; then
|
||||
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: about to run: $MD2HTML -v $V_FLAG -- $README_MD $INDEX_HTML" 1>&2
|
||||
echo "$0: debug[3]: about to run: $MD2HTML_SH -v $V_FLAG -- $README_MD $INDEX_HTML" 1>&2
|
||||
fi
|
||||
"$MD2HTML" -v "$V_FLAG" -- "$README_MD" "$INDEX_HTML"
|
||||
"$MD2HTML_SH" -v "$V_FLAG" -- "$README_MD" "$INDEX_HTML"
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: $MD2HTML -v $V_FLAG -- $README_MD $INDEX_HTML filed," \
|
||||
echo "$0: ERROR: $MD2HTML_SH -v $V_FLAG -- $README_MD $INDEX_HTML filed," \
|
||||
"error code: $status" 1>&2
|
||||
exit 32
|
||||
fi
|
||||
|
||||
+12
-5
@@ -304,8 +304,7 @@ while getopts :hv:Vd:D:nNj: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
#
|
||||
# remove the options
|
||||
#
|
||||
shift $(( OPTIND - 1 ));
|
||||
@@ -433,11 +432,19 @@ fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
|
||||
# find the jval-wrapper.sh tool
|
||||
# verify that the bin/jval-wrapper.sh tool is executable
|
||||
#
|
||||
JVAL_WRAPPER="$BIN_PATH/jval-wrapper.sh"
|
||||
JVAL_WRAPPER="$BIN_DIR/jval-wrapper.sh"
|
||||
if [[ ! -e $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh does not exist: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh is not a regular file: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: cannot find the bin/jval-wrapper.sh executable" 1>&2
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh is not an executable file: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -233,7 +234,7 @@ while getopts :hv:Vd:nN flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# remove the options
|
||||
#
|
||||
shift $(( OPTIND - 1 ));
|
||||
@@ -257,6 +258,7 @@ if [[ $V_FLAG -ge 1 ]]; then
|
||||
echo "$0: debug[1]: start scan for missing links" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# print running info if verbose
|
||||
#
|
||||
# If -v 3 or higher, print exported variables in order that they were exported.
|
||||
@@ -505,18 +507,21 @@ find . -name '*.md' ! -name markdown.md ! -path './tmp/*' -print |
|
||||
done
|
||||
done > "$TMP_MISSING_LINK"
|
||||
|
||||
|
||||
# count the missing links
|
||||
#
|
||||
MISSING_LINK_COUNT=$(wc -l < "$TMP_MISSING_LINK" | tr -d ' ')
|
||||
export MISSING_LINK_COUNT
|
||||
((MISSING_LINK_COUNT=MISSING_LINK_COUNT/4))
|
||||
|
||||
|
||||
# report on any missing links
|
||||
#
|
||||
if [[ -s $TMP_MISSING_LINK ]]; then
|
||||
sed -e "s;^$TOPDIR/;;" "$TMP_MISSING_LINK" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
if [[ -s $TMP_MISSING_LINK ]]; then
|
||||
|
||||
@@ -33,6 +33,9 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# modify well known markdown headers that are not in canonical form
|
||||
#
|
||||
for i in $(git ls-files '[0-9][0-9][0-9][0-9]/*README.md'); do
|
||||
perl -0777 -p -i -e 's/([^\n]\n)\n*##*[[:space:]]*(To build):?\n\n*([^\n])?/$1\n\n## $2:\n\n$3/' "$i"
|
||||
perl -0777 -p -i -e 's/([^\n]\n)\n*##*[[:space:]]*(Bugs and \(Mis\)features):?\n\n*([^\n])?/$1\n\n### $2:\n\n$3/' "$i"
|
||||
|
||||
+74
-29
@@ -28,6 +28,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -71,6 +72,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -83,9 +85,10 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.11 2024-08-13"
|
||||
export VERSION="1.12 2024-08-18"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -115,6 +118,7 @@ export DO_NOT_PROCESS=
|
||||
export QUICK_MODE=
|
||||
export EXIT_CODE="0"
|
||||
|
||||
|
||||
# Letter "is for" text
|
||||
#
|
||||
unset IS_FOR
|
||||
@@ -146,15 +150,17 @@ IS_FOR[x]="<i>x</i> is for <code>xor</code>"
|
||||
IS_FOR[y]="<i>y</i> is for <code>y0</code>"
|
||||
IS_FOR[z]="<i>z</i> is for <code>zlib</code>"
|
||||
|
||||
|
||||
# clear options we will add to tools
|
||||
#
|
||||
unset TOOL_OPTION
|
||||
declare -ag TOOL_OPTION
|
||||
|
||||
|
||||
# usage
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
[-t tagline] [-T md2html.sh] [-p tool] [-Q]
|
||||
[-t tagline] [-Q]
|
||||
|
||||
-h print help message and exit
|
||||
-v level set verbosity level (def level: 0)
|
||||
@@ -172,10 +178,6 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
|
||||
-t tagline string to write about the tool that formed the markdown content (def: $TAGLINE)
|
||||
NOTE: 'tagline' may be enclosed within, but may NOT contain an internal single-quote, or double-quote.
|
||||
-T md2html.sh run 'markdown to html tool' to convert markdown into HTML (def: $MD2HTML_SH)
|
||||
|
||||
-p tool run 'pandoc wrapper tool' (not pandoc path) during HTML phase number 21 (def: use $PANDOC_WRAPPER)
|
||||
NOTE: The '-p tool' is passed as leading options on tool command lines.
|
||||
|
||||
-Q quick mode, do not run $MD2HTML_SH unless markdown is out of date (def: do)
|
||||
|
||||
@@ -184,7 +186,7 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
|
||||
NOTE: The '-v level' is passed as initial command line options to the 'markdown to html tool' (md2html.sh).
|
||||
The 'tagline' is passed as '-t tagline' to the 'markdown to html tool' (md2html.sh), after the '-v level'.
|
||||
Any '-T md2html.sh', '-p tool', '-P pandoc_opts', '-U top_url'
|
||||
Any '-P pandoc_opts', '-U top_url'
|
||||
are passed to the 'markdown to html tool' (md2html.sh), and will be before any command line arguments.
|
||||
|
||||
Exit codes:
|
||||
@@ -200,6 +202,7 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# output_entry_ids
|
||||
#
|
||||
# Write the entry ids from an author/author_handle.json file to standard output (stdout)
|
||||
@@ -242,6 +245,7 @@ function output_entry_ids
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# output_author_handle
|
||||
#
|
||||
# Write the author handles from an author/author_handle.json file to standard output (stdout)
|
||||
@@ -283,6 +287,7 @@ function output_author_handle
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# output_full_name
|
||||
#
|
||||
# Write the Full Name from an author/author_handle.json file to standard output (stdout)
|
||||
@@ -324,6 +329,7 @@ function output_full_name
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# output_location_code
|
||||
#
|
||||
# Write the Location Code from an author/author_handle.json file to standard output (stdout)
|
||||
@@ -365,6 +371,7 @@ function output_location_code
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# output_award
|
||||
#
|
||||
# Write the award name to standard output (stdout)
|
||||
@@ -406,6 +413,7 @@ function output_award
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# output_url
|
||||
#
|
||||
# Write the url from an author/author_handle.json file to standard output (stdout)
|
||||
@@ -451,6 +459,7 @@ function output_url
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# output_alt_url
|
||||
#
|
||||
# Write the alternate url from an author/author_handle.json file to standard output (stdout)
|
||||
@@ -496,6 +505,7 @@ function output_alt_url
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# output_mastodon
|
||||
#
|
||||
# Write the mastodon handle from an author/author_handle.json file to standard output (stdout)
|
||||
@@ -541,6 +551,7 @@ function output_mastodon
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# output_mastodon_url
|
||||
#
|
||||
# Write the mastodon handle from an author/author_handle.json file to standard output (stdout)
|
||||
@@ -586,6 +597,7 @@ function output_mastodon_url
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# output_github
|
||||
#
|
||||
# Write the GitHub handle from an author/author_handle.json file to standard output (stdout)
|
||||
@@ -631,6 +643,7 @@ function output_github
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# output_affiliation
|
||||
#
|
||||
# Write the affiliation from an author/author_handle.json file to standard output (stdout)
|
||||
@@ -676,9 +689,10 @@ function output_affiliation
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNt:T:p:Qw: flag; do
|
||||
while getopts :hv:Vd:D:nNt:Qw: flag; do
|
||||
case "$flag" in
|
||||
h) echo "$USAGE" 1>&2
|
||||
exit 2
|
||||
@@ -727,14 +741,6 @@ while getopts :hv:Vd:D:nNt:T:p:Qw: flag; do
|
||||
TAGLINE="$OPTARG"
|
||||
# -t tagline always added after arg parsing
|
||||
;;
|
||||
T) MD2HTML_SH="$OPTARG"
|
||||
TOOL_OPTION+=("-T")
|
||||
TOOL_OPTION+=("$MD2HTML_SH")
|
||||
;;
|
||||
p) PANDOC_WRAPPER="$OPTARG"
|
||||
TOOL_OPTION+=("-p")
|
||||
TOOL_OPTION+=("$PANDOC_WRAPPER")
|
||||
;;
|
||||
Q) QUICK_MODE="-Q"
|
||||
;;
|
||||
w) SITE_URL="$OPTARG"
|
||||
@@ -758,7 +764,7 @@ while getopts :hv:Vd:D:nNt:T:p:Qw: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# remove the options
|
||||
#
|
||||
shift $(( OPTIND - 1 ));
|
||||
@@ -774,6 +780,7 @@ if [[ $# -ne 0 ]]; then
|
||||
exit 3
|
||||
fi
|
||||
|
||||
|
||||
# always add the '-v level' option, unless level is empty, to the set of options passed to the md2html.sh tool
|
||||
#
|
||||
if [[ -n $V_FLAG ]]; then
|
||||
@@ -788,16 +795,19 @@ if [[ -n $TAGLINE ]]; then
|
||||
TOOL_OPTION+=("$TAGLINE")
|
||||
fi
|
||||
|
||||
|
||||
# always add the '-U URL' for the top level authors.html file
|
||||
#
|
||||
TOOL_OPTION+=("-U")
|
||||
TOOL_OPTION+=("$SITE_URL/authors.html")
|
||||
|
||||
|
||||
# always add the '-D docroot/' for the top level authors.html file
|
||||
#
|
||||
TOOL_OPTION+=("-D")
|
||||
TOOL_OPTION+=("$DOCROOT_SLASH")
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -818,6 +828,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -841,6 +852,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that the md2html tool is executable
|
||||
#
|
||||
if [[ ! -e $MD2HTML_SH ]]; then
|
||||
@@ -856,6 +868,7 @@ if [[ ! -x $MD2HTML_SH ]]; then
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have an author subdirectory
|
||||
#
|
||||
export AUTHOR_PATH="$TOPDIR/author"
|
||||
@@ -865,6 +878,7 @@ if [[ ! -d $AUTHOR_PATH ]]; then
|
||||
fi
|
||||
export AUTHOR_DIR="author"
|
||||
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
@@ -874,33 +888,40 @@ if [[ ! -d $BIN_PATH ]]; then
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# find the jval-wrapper.sh tool
|
||||
|
||||
# verify that the bin/jval-wrapper.sh tool is executable
|
||||
#
|
||||
JVAL_WRAPPER="$BIN_PATH/jval-wrapper.sh"
|
||||
if [[ ! -x $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: cannot find the bin/jval-wrapper.sh executable" 1>&2
|
||||
JVAL_WRAPPER="$BIN_DIR/jval-wrapper.sh"
|
||||
if [[ ! -e $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh does not exist: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh is not a regular file: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh is not an executable file: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# find the location tool
|
||||
#
|
||||
LOCATION_TOOL=$(type -P location)
|
||||
export LOCATION_TOOL
|
||||
if [[ -z $LOCATION_TOOL ]]; then
|
||||
# guess we have a location tool in bin
|
||||
#
|
||||
LOCATION_TOOL="$BIN_DIR/location"
|
||||
fi
|
||||
if [[ ! -x $LOCATION_TOOL ]]; then
|
||||
echo "$0: ERROR: cannot find the location executable" 1>&2
|
||||
echo "$0: ERROR: cannot find the location executable along \$PATH" 1>&2
|
||||
echo "$0: notice: location tool comes from this repo: https://github.com/ioccc-src/mkiocccentry" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# note authors.html file
|
||||
#
|
||||
export AUTHORS_HTML="authors.html"
|
||||
|
||||
|
||||
# print running info if verbose
|
||||
#
|
||||
# If -v 3 or higher, print exported variables in order that they were exported.
|
||||
@@ -939,6 +960,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: AUTHORS_HTML=$AUTHORS_HTML" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# -N stops early before any processing is performed
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -948,7 +970,8 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# case: -Q
|
||||
|
||||
# case: -Q (quick mode)
|
||||
#
|
||||
# Do nothing if authors.html is newer than all author/author_handle.json files.
|
||||
#
|
||||
@@ -959,6 +982,7 @@ if [[ -n $QUICK_MODE ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary entry markdown file
|
||||
#
|
||||
export TMP_AUTHORS_MD=".tmp.$NAME.AUTHORS_MD.$$.tmp"
|
||||
@@ -981,6 +1005,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary entry markdown file is not used: $TMP_AUTHORS_MD" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary sort word list file
|
||||
#
|
||||
export TMP_SORT_WORD=".tmp.$NAME.SORT_WORD.$$.tmp"
|
||||
@@ -1003,12 +1028,14 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary sort word list file is not used: $TMP_SORT_WORD" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# load initial letter . lines into the temporary sort word list file
|
||||
#
|
||||
for letter in "${!IS_FOR[@]}"; do
|
||||
echo "$letter ."
|
||||
done > "$TMP_SORT_WORD"
|
||||
|
||||
|
||||
# add author sort_word filename to the temporary sort word list file
|
||||
#
|
||||
if [[ $V_FLAG -ge 1 ]]; then
|
||||
@@ -1018,6 +1045,7 @@ find "$AUTHOR_DIR" -mindepth 1 -maxdepth 1 -type f -name '*.json' 2>/dev/null |
|
||||
echo "$(bin/jval-wrapper.sh -w -b "$json_file" '$..sort_word') $json_file"
|
||||
done >> "$TMP_SORT_WORD"
|
||||
|
||||
|
||||
# sort the temporary sort word list file
|
||||
#
|
||||
LC_ALL=C sort -f -d "$TMP_SORT_WORD" -o "$TMP_SORT_WORD"
|
||||
@@ -1027,6 +1055,7 @@ if [[ $status -ne 0 ]]; then
|
||||
exit 14
|
||||
fi
|
||||
|
||||
|
||||
# generate the temporary entry markdown file
|
||||
#
|
||||
{
|
||||
@@ -1299,9 +1328,13 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
# use the md2html.sh tool to form a location HTML file, unless -n
|
||||
|
||||
# use the md2html.sh tool to update authors.html, unless -n
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
|
||||
# possibly update authors.html
|
||||
#
|
||||
if [[ $V_FLAG -ge 1 ]]; then
|
||||
echo "$0: debug[1]: about to run: $MD2HTML_SH ${TOOL_OPTION[*]} -- authors.md $TMP_AUTHORS_MD $AUTHORS_HTML" 1>&2
|
||||
fi
|
||||
@@ -1316,12 +1349,23 @@ if [[ -z $NOOP ]]; then
|
||||
echo "$0: debug[3]: now up to date: $AUTHORS_HTML" 1>&2
|
||||
fi
|
||||
|
||||
# case -Q: (quick mode)
|
||||
#
|
||||
# If we are here, then the early quick mode test indicated that the prerequisite files are newer.
|
||||
# We will force the authors.html file to be touched so that a later run with -Q will quickly exit.
|
||||
# We do this because by default, the md2html.sh tool does not modify the target HTML unless it was modified.
|
||||
#
|
||||
if [[ -n $QUICK_MODE ]]; then
|
||||
touch "$AUTHORS_HTML"
|
||||
fi
|
||||
|
||||
# report disabled by -n
|
||||
#
|
||||
elif [[ $V_FLAG -ge 5 ]]; then
|
||||
echo "$0: debug[5]: because of -n, did not run: $MD2HTML_SH ${TOOL_OPTION[*]} -- authors.md $TMP_AUTHORS_MD $AUTHORS_HTML" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# file cleanup
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -1330,6 +1374,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, disabled: rm -f -- $TMP_AUTHORS_MD" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
if [[ $EXIT_CODE -ne 0 ]]; then
|
||||
|
||||
+48
-27
@@ -26,6 +26,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -84,7 +85,7 @@ shopt -s globstar # enable ** to match all files and zero or more directories an
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.5 2024-08-17"
|
||||
export VERSION="1.6 2024-08-18"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -110,17 +111,19 @@ export SITE_URL="https://ioccc-src.github.io/temp-test-ioccc"
|
||||
#
|
||||
export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
QUICK_MODE=
|
||||
export QUICK_MODE=
|
||||
|
||||
|
||||
# clear options we will add to tools
|
||||
#
|
||||
unset TOOL_OPTION
|
||||
declare -ag TOOL_OPTION
|
||||
|
||||
|
||||
# usage
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
[-t tagline] [-p tool] [-Q] [-w site_url]
|
||||
[-t tagline] [-Q] [-w site_url]
|
||||
|
||||
-h print help message and exit
|
||||
-v level set verbosity level (def level: 0)
|
||||
@@ -139,9 +142,6 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
-t tagline string to write about the tool that formed the markdown content (def: $TAGLINE)
|
||||
NOTE: 'tagline' may be enclosed within, but may NOT contain an internal single-quote, or double-quote.
|
||||
|
||||
-p tool run 'pandoc wrapper tool' (not pandoc path) during HTML phase number 21 (def: use $PANDOC_WRAPPER)
|
||||
NOTE: The '-p tool' is passed as leading options on tool command lines.
|
||||
|
||||
-Q quick mode, do not run $MD2HTML_SH unless markdown is out of date (def: do)
|
||||
|
||||
-w site_url Base URL of the website (def: $SITE_URL)
|
||||
@@ -149,7 +149,7 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
|
||||
NOTE: The '-v level' is passed as initial command line options to the 'markdown to html tool' (md2html.sh).
|
||||
The 'tagline' is passed as '-t tagline' to the 'markdown to html tool' (md2html.sh), after the '-v level'.
|
||||
Any '-T md2html.sh', '-p tool', '-P pandoc_opts', '-U top_url'
|
||||
Any '-P pandoc_opts', '-U top_url'
|
||||
are passed to the 'markdown to html tool' (md2html.sh), and will be before any command line arguments.
|
||||
|
||||
Exit codes:
|
||||
@@ -165,9 +165,10 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNt:p:Qw: flag; do
|
||||
while getopts :hv:Vd:D:nNt:Qw: flag; do
|
||||
case "$flag" in
|
||||
h) echo "$USAGE" 1>&2
|
||||
exit 2
|
||||
@@ -216,10 +217,6 @@ while getopts :hv:Vd:D:nNt:p:Qw: flag; do
|
||||
TAGLINE="$OPTARG"
|
||||
# -t tagline always added after arg parsing
|
||||
;;
|
||||
p) PANDOC_WRAPPER="$OPTARG"
|
||||
TOOL_OPTION+=("-p")
|
||||
TOOL_OPTION+=("$PANDOC_WRAPPER")
|
||||
;;
|
||||
Q) QUICK_MODE="-Q"
|
||||
;;
|
||||
w) SITE_URL="$OPTARG"
|
||||
@@ -243,7 +240,7 @@ while getopts :hv:Vd:D:nNt:p:Qw: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# remove the options
|
||||
#
|
||||
shift $(( OPTIND - 1 ));
|
||||
@@ -259,6 +256,7 @@ if [[ $# -ne 0 ]]; then
|
||||
exit 3
|
||||
fi
|
||||
|
||||
|
||||
# always add the '-v level' option, unless level is empty, to the set of options passed to the md2html.sh tool
|
||||
#
|
||||
if [[ -n $V_FLAG ]]; then
|
||||
@@ -266,6 +264,7 @@ if [[ -n $V_FLAG ]]; then
|
||||
TOOL_OPTION+=("$V_FLAG")
|
||||
fi
|
||||
|
||||
|
||||
# always add the '-t tagline' option, unless tagline is empty, to the set of options passed to the md2html.sh tool
|
||||
#
|
||||
if [[ -n $TAGLINE ]]; then
|
||||
@@ -273,16 +272,19 @@ if [[ -n $TAGLINE ]]; then
|
||||
TOOL_OPTION+=("$TAGLINE")
|
||||
fi
|
||||
|
||||
|
||||
# always add the '-U URL' for the top level location.html file
|
||||
#
|
||||
TOOL_OPTION+=("-U")
|
||||
TOOL_OPTION+=("$SITE_URL/location.html")
|
||||
|
||||
|
||||
# always add the '-D docroot/' for the top level location.html file
|
||||
#
|
||||
TOOL_OPTION+=("-D")
|
||||
TOOL_OPTION+=("$DOCROOT_SLASH")
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -303,6 +305,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -326,6 +329,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have an author subdirectory
|
||||
#
|
||||
export AUTHOR_PATH="$TOPDIR/author"
|
||||
@@ -335,6 +339,7 @@ if [[ ! -d $AUTHOR_PATH ]]; then
|
||||
fi
|
||||
export AUTHOR_DIR="author"
|
||||
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
@@ -344,7 +349,8 @@ if [[ ! -d $BIN_PATH ]]; then
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# verify that the md2html tool is executable
|
||||
|
||||
# verify that the bin/md2html.sh tool is executable
|
||||
#
|
||||
export MD2HTML_SH="$BIN_DIR/md2html.sh"
|
||||
if [[ ! -e $MD2HTML_SH ]]; then
|
||||
@@ -360,42 +366,40 @@ if [[ ! -x $MD2HTML_SH ]]; then
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# verify jval-wrapper tool is executable
|
||||
|
||||
# verify that the bin/jval-wrapper.sh tool is executable
|
||||
#
|
||||
export JVAL_WRAPPER="$BIN_DIR/jval-wrapper.sh"
|
||||
JVAL_WRAPPER="$BIN_DIR/jval-wrapper.sh"
|
||||
if [[ ! -e $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh file does not exist: $JVAL_WRAPPER" 1>&2
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh does not exist: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh is not a file: $JVAL_WRAPPER" 1>&2
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh is not a regular file: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: cannot find an executable bin/jval-wrapper.sh tool: $JVAL_WRAPPER" 1>&2
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh is not an executable file: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
#
|
||||
|
||||
|
||||
# find the location tool
|
||||
#
|
||||
LOCATION_TOOL=$(type -P location)
|
||||
export LOCATION_TOOL
|
||||
if [[ -z $LOCATION_TOOL ]]; then
|
||||
# guess we have a location tool in bin
|
||||
#
|
||||
LOCATION_TOOL="$BIN_DIR/location"
|
||||
fi
|
||||
if [[ ! -x $LOCATION_TOOL ]]; then
|
||||
echo "$0: ERROR: cannot find the location executable" 1>&2
|
||||
echo "$0: ERROR: cannot find the location executable along \$PATH" 1>&2
|
||||
echo "$0: notice: location tool comes from this repo: https://github.com/ioccc-src/mkiocccentry" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# note location.html file
|
||||
#
|
||||
export LOCATION_HTML="location.html"
|
||||
|
||||
|
||||
# print running info if verbose
|
||||
#
|
||||
# If -v 3 or higher, print exported variables in order that they were exported.
|
||||
@@ -440,7 +444,8 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# case: -Q
|
||||
|
||||
# case: -Q (quick mode)
|
||||
#
|
||||
# Do nothing if authors.html is newer than all author/author_handle.json files.
|
||||
#
|
||||
@@ -451,6 +456,7 @@ if [[ -n $QUICK_MODE ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary location markdown file
|
||||
#
|
||||
export TMP_LOC_MD=".tmp.$NAME.LOC_MD.$$.tmp"
|
||||
@@ -473,6 +479,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary location markdown file is not used: $TMP_LOC_MD" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary location sort_word handle name set
|
||||
#
|
||||
export TMP_LOC_WORD_HANDLE_NAME_SET=".tmp.$NAME.LOC_AUTHOR_HANDLE.$$.tmp"
|
||||
@@ -495,6 +502,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary location sort_word handle name set is not used: $TMP_LOC_WORD_HANDLE_NAME_SET" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary location count set
|
||||
#
|
||||
export TMP_LOC_COUNT=".tmp.$NAME.LOC_COUNT.$$.tmp"
|
||||
@@ -722,6 +730,9 @@ done < "$TMP_LOC_WORD_HANDLE_NAME_SET" > "$TMP_LOC_MD"
|
||||
# use the md2html.sh tool to form a location HTML file, unless -n
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
|
||||
# possibly update location.html
|
||||
#
|
||||
if [[ $V_FLAG -ge 1 ]]; then
|
||||
echo "$0: debug[1]: about to run: $MD2HTML_SH ${TOOL_OPTION[*]} -- location.md $TMP_LOC_MD $LOCATION_HTML" 1>&2
|
||||
fi
|
||||
@@ -735,6 +746,16 @@ if [[ -z $NOOP ]]; then
|
||||
echo "$0: debug[3]: now up to date: $LOCATION_HTML" 1>&2
|
||||
fi
|
||||
|
||||
# case -Q: (quick mode)
|
||||
#
|
||||
# If we are here, then the early quick mode test indicated that the prerequisite files are newer.
|
||||
# We will force the authors.html file to be touched so that a later run with -Q will quickly exit.
|
||||
# We do this because by default, the md2html.sh tool does not modify the target HTML unless it was modified.
|
||||
#
|
||||
if [[ -n $QUICK_MODE ]]; then
|
||||
touch "$LOCATION_HTML"
|
||||
fi
|
||||
|
||||
# report disabled by -n
|
||||
#
|
||||
elif [[ $V_FLAG -ge 5 ]]; then
|
||||
|
||||
+69
-32
@@ -26,6 +26,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -82,9 +83,10 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.3 2024-08-11"
|
||||
export VERSION="1.4 2024-08-17"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -114,15 +116,17 @@ export DO_NOT_PROCESS=
|
||||
export QUICK_MODE=
|
||||
export EXIT_CODE="0"
|
||||
|
||||
|
||||
# clear options we will add to tools
|
||||
#
|
||||
unset TOOL_OPTION
|
||||
declare -ag TOOL_OPTION
|
||||
|
||||
|
||||
# usage
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
[-t tagline] [-T md2html.sh] [-p tool] [-Q] [-w site_url]
|
||||
[-t tagline] [-Q] [-w site_url]
|
||||
|
||||
-h print help message and exit
|
||||
-v level set verbosity level (def level: 0)
|
||||
@@ -138,17 +142,13 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
|
||||
-t tagline string to write about the tool that formed the markdown content (def: $TAGLINE)
|
||||
NOTE: The '-t tagline' is passed as leading options on tool command lines.
|
||||
-T md2html.sh run 'markdown to html tool' to convert markdown into HTML (def: $MD2HTML_SH)
|
||||
NOTE: The '-T md2html.sh' is passed as leading options on tool command lines.
|
||||
|
||||
-Q quick mode, do not run $MD2HTML_SH unless markdown is out of date (def: do)
|
||||
|
||||
-p tool run 'pandoc wrapper tool' (not pandoc path) during HTML phase number 21 (def: use $PANDOC_WRAPPER)
|
||||
|
||||
-w site_url Base URL of the website (def: $SITE_URL)
|
||||
NOTE: The '-w site_url' is passed as leading options on tool command lines.
|
||||
|
||||
NOTE: Any '-D docroot/', '-t tagline', '-T md2html.sh', '-p tool', '-w site_url'
|
||||
NOTE: Any '-D docroot/', '-t tagline', '-w site_url'
|
||||
are passed to the 'tool' at the beginning of the command line, and
|
||||
before any optional 'more_options' and before the final YYYY/dir argument.
|
||||
|
||||
@@ -168,7 +168,7 @@ $NAME version: $VERSION"
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNt:T:p:Qw: flag; do
|
||||
while getopts :hv:Vd:D:nNt:Qw: flag; do
|
||||
case "$flag" in
|
||||
h) echo "$USAGE" 1>&2
|
||||
exit 2
|
||||
@@ -215,14 +215,6 @@ while getopts :hv:Vd:D:nNt:T:p:Qw: flag; do
|
||||
esac
|
||||
TAGLINE="$OPTARG"
|
||||
;;
|
||||
T) MD2HTML_SH="$OPTARG"
|
||||
TOOL_OPTION+=("-T")
|
||||
TOOL_OPTION+=("$MD2HTML_SH")
|
||||
;;
|
||||
p) PANDOC_WRAPPER="$OPTARG"
|
||||
TOOL_OPTION+=("-p")
|
||||
TOOL_OPTION+=("$PANDOC_WRAPPER")
|
||||
;;
|
||||
Q) QUICK_MODE="-Q"
|
||||
;;
|
||||
w) SITE_URL="$OPTARG"
|
||||
@@ -244,7 +236,7 @@ while getopts :hv:Vd:D:nNt:T:p:Qw: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# remove the options
|
||||
#
|
||||
shift $(( OPTIND - 1 ));
|
||||
@@ -259,6 +251,7 @@ if [[ $# -ne 0 ]]; then
|
||||
exit 3
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -279,6 +272,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -302,6 +296,34 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
if [[ ! -d $BIN_PATH ]]; then
|
||||
echo "$0: ERROR: bin is not a directory under topdir: $BIN_PATH" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
|
||||
# verify that the bin/md2html.sh tool is executable
|
||||
#
|
||||
export MD2HTML_SH="$BIN_DIR/md2html.sh"
|
||||
if [[ ! -e $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh does not exist: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not a regular file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not an executable file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify we have a non-empty readable .top file
|
||||
#
|
||||
export TOP_FILE=".top"
|
||||
@@ -322,20 +344,6 @@ if [[ ! -s $TOP_FILE ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify that the md2html.sh is an executable file
|
||||
#
|
||||
if [[ ! -e $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: md2html.sh does not exist: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: md2html.sh is not a regular file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: md2html.sh is not an executable file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# always set the tagline
|
||||
#
|
||||
@@ -344,6 +352,7 @@ TOOL_OPTION+=("$TAGLINE")
|
||||
TOOL_OPTION+=("-w")
|
||||
TOOL_OPTION+=("$SITE_URL")
|
||||
|
||||
|
||||
# print running info if verbose
|
||||
#
|
||||
# If -v 3 or higher, print exported variables in order that they were exported.
|
||||
@@ -356,7 +365,6 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: TOPDIR=$TOPDIR" 1>&2
|
||||
echo "$0: debug[3]: DOCROOT_SLASH=$DOCROOT_SLASH" 1>&2
|
||||
echo "$0: debug[3]: TAGLINE=$TAGLINE" 1>&2
|
||||
echo "$0: debug[3]: MD2HTML_SH=$MD2HTML_SH" 1>&2
|
||||
echo "$0: debug[3]: PANDOC_WRAPPER=$PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: REPO_TOP_URL=$REPO_TOP_URL" 1>&2
|
||||
echo "$0: debug[3]: REPO_URL=$REPO_URL" 1>&2
|
||||
@@ -370,9 +378,13 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
done
|
||||
echo "$0: debug[3]: REPO_NAME=$REPO_NAME" 1>&2
|
||||
echo "$0: debug[3]: CD_FAILED=$CD_FAILED" 1>&2
|
||||
echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2
|
||||
echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2
|
||||
echo "$0: debug[3]: MD2HTML_SH=$MD2HTML_SH" 1>&2
|
||||
echo "$0: debug[3]: TOP_FILE=$TOP_FILE" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# -N stops early before any processing is performed
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -382,6 +394,7 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary exit code
|
||||
#
|
||||
# It is a pain to set the EXIT_CODE deep inside a loop, so we write the EXIT_CODE into a file
|
||||
@@ -407,6 +420,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary exit code is not used: $TMP_EXIT_CODE" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# process each year
|
||||
#
|
||||
export YYYY
|
||||
@@ -585,6 +599,8 @@ for YYYY in $(< "$TOP_FILE"); do
|
||||
HTML_BASENAME=$(basename "$HTML_FILE")
|
||||
export HTML_BASENAME
|
||||
|
||||
# case: -Q (quick mode)
|
||||
#
|
||||
# determine if we need to run the tool
|
||||
#
|
||||
# Check if the non-empty foo.html is newer than foo.md.
|
||||
@@ -599,6 +615,14 @@ for YYYY in $(< "$TOP_FILE"); do
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: does not need to be updated: $HTML_FILE" 1>&2
|
||||
fi
|
||||
|
||||
# case -Q: (quick mode)
|
||||
#
|
||||
# If we are here, then the early quick mode test indicated that the prerequisite files are newer.
|
||||
# We will force the authors.html file to be touched so that a later run with -Q will quickly exit.
|
||||
# We do this because by default, the md2html.sh tool does not modify the target HTML unless it was modified.
|
||||
#
|
||||
touch "$HTML_FILE"
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
@@ -651,6 +675,8 @@ for YYYY in $(< "$TOP_FILE"); do
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
|
||||
# possibly update the HTML file
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: about to run: $MD2HTML_SH ${TOOL_OPTION[*]}" \
|
||||
"-U $SITE_URL/$HTML_FILE" \
|
||||
@@ -678,6 +704,16 @@ for YYYY in $(< "$TOP_FILE"); do
|
||||
continue
|
||||
fi
|
||||
|
||||
# case -Q: (quick mode)
|
||||
#
|
||||
# If we are here, then the early quick mode test indicated that the prerequisite files are newer.
|
||||
# We will force the authors.html file to be touched so that a later run with -Q will quickly exit.
|
||||
# We do this because by default, the md2html.sh tool does not modify the target HTML unless it was modified.
|
||||
#
|
||||
if [[ -n $QUICK_MODE ]]; then
|
||||
touch "$HTML_FILE"
|
||||
fi
|
||||
|
||||
# report disabled by -n
|
||||
#
|
||||
elif [[ $V_FLAG -ge 5 ]]; then
|
||||
@@ -697,6 +733,7 @@ if [[ -z $NOOP ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
if [[ $EXIT_CODE -ne 0 ]]; then
|
||||
|
||||
+42
-15
@@ -26,6 +26,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -82,6 +83,7 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.3.14 2024-08-19"
|
||||
@@ -194,6 +196,7 @@ function output_modtime
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# set usage message
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N]
|
||||
@@ -228,12 +231,14 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# setup
|
||||
#
|
||||
export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
export EXIT_CODE="0"
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:nNw:W flag; do
|
||||
@@ -273,7 +278,7 @@ while getopts :hv:Vd:nNw:W flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# parse the command line arguments
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -289,7 +294,7 @@ if [[ $# -ne 0 ]]; then
|
||||
echo "$0: ERROR: expected 0 args, found: $#" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
#
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
@@ -311,6 +316,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -334,6 +340,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have an archive/historic subdirectory
|
||||
#
|
||||
export ARCHIVE_HISTORIC_PATH="$TOPDIR/archive/historic"
|
||||
@@ -343,6 +350,7 @@ if [[ ! -d $ARCHIVE_HISTORIC_PATH ]]; then
|
||||
fi
|
||||
export ARCHIVE_HISTORIC_DIR="archive/historic"
|
||||
|
||||
|
||||
# verify that we have an author subdirectory
|
||||
#
|
||||
export AUTHOR_PATH="$TOPDIR/author"
|
||||
@@ -352,6 +360,7 @@ if [[ ! -d $AUTHOR_PATH ]]; then
|
||||
fi
|
||||
export AUTHOR_DIR="author"
|
||||
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
@@ -361,18 +370,6 @@ if [[ ! -d $BIN_PATH ]]; then
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# verify that we have an inc subdirectory
|
||||
#
|
||||
export INC_PATH="$TOPDIR/inc"
|
||||
if [[ ! -d $INC_PATH ]]; then
|
||||
echo "$0: ERROR: inc is not a directory under topdir: $INC_PATH" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export INC_DIR="inc"
|
||||
|
||||
# determine the name of sitemap
|
||||
#
|
||||
export SITEMAP="sitemap.xml"
|
||||
|
||||
# verify we have our awk tool
|
||||
#
|
||||
@@ -394,6 +391,22 @@ if [[ ! -s $FILELIST_ENTRY_JSON_AWK ]]; then
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have an inc subdirectory
|
||||
#
|
||||
export INC_PATH="$TOPDIR/inc"
|
||||
if [[ ! -d $INC_PATH ]]; then
|
||||
echo "$0: ERROR: inc is not a directory under topdir: $INC_PATH" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export INC_DIR="inc"
|
||||
|
||||
|
||||
# determine the name of sitemap
|
||||
#
|
||||
export SITEMAP="sitemap.xml"
|
||||
|
||||
|
||||
# verify we have a non-empty readable .top file
|
||||
#
|
||||
export TOP_FILE=".top"
|
||||
@@ -414,6 +427,7 @@ if [[ ! -s $TOP_FILE ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# determine how we can determine the file modification time in W3C Datetime format:
|
||||
#
|
||||
# https://www.w3.org/TR/NOTE-datetime
|
||||
@@ -471,6 +485,7 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# parameter debugging
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -498,12 +513,13 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2
|
||||
echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2
|
||||
echo "$0: debug[3]: INC_PATH=$INC_PATH" 1>&2
|
||||
echo "$0: debug[3]: FILELIST_ENTRY_JSON_AWK=$FILELIST_ENTRY_JSON_AWK" 1>&2
|
||||
echo "$0: debug[3]: INC_DIR=$INC_DIR" 1>&2
|
||||
echo "$0: debug[3]: SITEMAP=$SITEMAP" 1>&2
|
||||
echo "$0: debug[3]: FILELIST_ENTRY_JSON_AWK=$FILELIST_ENTRY_JSON_AWK" 1>&2
|
||||
echo "$0: debug[3]: TOP_FILE=$TOP_FILE" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# If -N, time to exit
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -513,6 +529,7 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary file manifest list
|
||||
#
|
||||
export TMP_MANIFEST_LIST=".tmp.$NAME.MANIFEST_LIST.$$.tmp"
|
||||
@@ -531,6 +548,7 @@ if [[ ! -e $TMP_MANIFEST_LIST ]]; then
|
||||
exit 11
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary exit code
|
||||
#
|
||||
# It is a pain to set the EXIT_CODE deep inside a loop, so we write the EXIT_CODE into a file
|
||||
@@ -552,6 +570,7 @@ if [[ ! -e $TMP_EXIT_CODE ]]; then
|
||||
exit 15
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary sitemap
|
||||
#
|
||||
export TMP_SITEMAP=".tmp.$NAME.SITEMAP.$$.tmp"
|
||||
@@ -570,6 +589,7 @@ if [[ ! -e $TMP_SITEMAP ]]; then
|
||||
exit 17
|
||||
fi
|
||||
|
||||
|
||||
# add top level files to the file manifest list
|
||||
#
|
||||
# We do not (yet?) include these files:
|
||||
@@ -611,10 +631,12 @@ winners.html
|
||||
years.html
|
||||
EOF0
|
||||
|
||||
|
||||
# add files from selected sub-directories
|
||||
#
|
||||
find "$ARCHIVE_HISTORIC_DIR" "$AUTHOR_DIR" "$BIN_DIR" "$INC_DIR" -type f -print >> "$TMP_MANIFEST_LIST"
|
||||
|
||||
|
||||
# generate sorted list of entry files from the full IOCCC manifest
|
||||
#
|
||||
# We also include the YYYY/.filelist contents.
|
||||
@@ -796,6 +818,7 @@ if [[ $EXIT_CODE -ne 0 ]]; then
|
||||
exit "$EXIT_CODE"
|
||||
fi
|
||||
|
||||
|
||||
# sort the manifest list
|
||||
#
|
||||
LC_ALL=C sort -d "$TMP_MANIFEST_LIST" -o "$TMP_MANIFEST_LIST"
|
||||
@@ -805,6 +828,7 @@ if [[ $status -ne 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# verify that the manifest list contains only readable files
|
||||
#
|
||||
for FILE in $(< "$TMP_MANIFEST_LIST"); do
|
||||
@@ -844,6 +868,7 @@ if [[ $EXIT_CODE -ne 0 ]]; then
|
||||
exit "$EXIT_CODE"
|
||||
fi
|
||||
|
||||
|
||||
# form the sitemap
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -897,6 +922,7 @@ if [[ -z $EXIT_CODE ]]; then
|
||||
exit 19
|
||||
fi
|
||||
|
||||
|
||||
# move the sitemap in place only if different
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -938,6 +964,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary file manifest list was not formed: $TMP_MANIFEST_LIST" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
|
||||
+90
-36
@@ -26,6 +26,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -82,9 +83,10 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.5.8 2024-08-05"
|
||||
export VERSION="1.6 2024-08-17"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -102,7 +104,6 @@ fi
|
||||
export TOPDIR
|
||||
export DOCROOT_SLASH="./"
|
||||
export TAGLINE="bin/$NAME"
|
||||
export MD2HTML_SH="bin/md2html.sh"
|
||||
export REPO_TOP_URL="https://github.com/ioccc-src/temp-test-ioccc"
|
||||
# GitHub puts individual files under the "blob/master" sub-directory.
|
||||
export REPO_URL="$REPO_TOP_URL/blob/master"
|
||||
@@ -124,19 +125,21 @@ if [[ -z "$LS_TOOL" ]]; then
|
||||
echo "$0: FATAL: ls tool is not installed or not in \$PATH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
#
|
||||
export IOCCC_STATUS_VERSION="1.0 2024-03-09"
|
||||
#
|
||||
export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
export EXIT_CODE="0"
|
||||
|
||||
|
||||
# clear options we will add to tools
|
||||
#
|
||||
unset TOOL_OPTION
|
||||
declare -ag TOOL_OPTION
|
||||
export MODTIME_METHOD=""
|
||||
|
||||
|
||||
# output_modtime - file modification time in W3C Datetime format:
|
||||
#
|
||||
# https://www.w3.org/TR/NOTE-datetime
|
||||
@@ -212,6 +215,7 @@ function output_modtime
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# output_status_json
|
||||
#
|
||||
# write a status.json file to standard output (stdout)
|
||||
@@ -290,13 +294,11 @@ function output_status_json
|
||||
|
||||
# determine the "contest_status" that was in status.json
|
||||
#
|
||||
OLD_CONTEST_STATUS=$(grep '"contest_status"[[:space:]]*:[[:space:]]*"' "$STATUS_PATH" |
|
||||
sed -e 's/^.*:[[:space:]]*"//' -e 's/",*//')
|
||||
OLD_CONTEST_STATUS=$("$JVAL_WRAPPER" -w -b "$STATUS_PATH" '$..contest_status')
|
||||
|
||||
# determine the "status_update" that was in status.json
|
||||
#
|
||||
OLD_STATUS_UPDATE=$(grep '"status_update"[[:space:]]*:[[:space:]]*"' "$STATUS_PATH" |
|
||||
sed -e 's/^.*:[[:space:]]*"//' -e 's/",*//')
|
||||
OLD_STATUS_UPDATE=$("$JVAL_WRAPPER" -w -b "$STATUS_PATH" '$..status_update')
|
||||
|
||||
# update the status.json file modification date if the "contest_status" changed
|
||||
#
|
||||
@@ -333,11 +335,11 @@ function output_status_json
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# usage
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N]
|
||||
[-t tagline] [-T md2html.sh]
|
||||
[p | pending | o | open | j | judging | c | closed]
|
||||
[-t tagline] [p | pending | o | open | j | judging | c | closed]
|
||||
|
||||
-h print help message and exit
|
||||
-v level set verbosity level (def level: 0)
|
||||
@@ -355,7 +357,6 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N]
|
||||
|
||||
-t tagline string to write about the tool that formed the markdown content (def: $TAGLINE)
|
||||
NOTE: 'tagline' may be enclosed within, but may NOT contain an internal single-quote, or double-quote.
|
||||
-T md2html.sh run 'markdown to html tool' to convert markdown into HTML (def: $MD2HTML_SH)
|
||||
|
||||
-w site_url Base URL of the website (def: $SITE_URL)
|
||||
NOTE: The '-w site_url' is passed as leading options on tool command lines.
|
||||
@@ -368,7 +369,7 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N]
|
||||
|
||||
NOTE: The '-v level' is passed as initial command line options to the 'markdown to html tool' (md2html.sh).
|
||||
The 'tagline' is passed as '-t tagline' to the 'markdown to html tool' (md2html.sh), after the '-v level'.
|
||||
Any '-T md2html.sh', '-p tool', '-P pandoc_opts', '-U top_url'
|
||||
Any '-P pandoc_opts', '-U top_url'
|
||||
are passed to the 'markdown to html tool' (md2html.sh), and will be before any command line arguments.
|
||||
|
||||
Exit codes:
|
||||
@@ -383,9 +384,10 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNt:T:w: flag; do
|
||||
while getopts :hv:Vd:D:nNt:w: flag; do
|
||||
case "$flag" in
|
||||
h) echo "$USAGE" 1>&2
|
||||
exit 2
|
||||
@@ -434,10 +436,6 @@ while getopts :hv:Vd:D:nNt:T:w: flag; do
|
||||
TAGLINE="$OPTARG"
|
||||
# -t tagline always added after arg parsing
|
||||
;;
|
||||
T) MD2HTML_SH="$OPTARG"
|
||||
TOOL_OPTION+=("-T")
|
||||
TOOL_OPTION+=("$MD2HTML_SH")
|
||||
;;
|
||||
w) SITE_URL="$OPTARG"
|
||||
TOOL_OPTION+=("-w")
|
||||
TOOL_OPTION+=("$SITE_URL")
|
||||
@@ -459,7 +457,7 @@ while getopts :hv:Vd:D:nNt:T:w: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# remove the options
|
||||
#
|
||||
shift $(( OPTIND - 1 ));
|
||||
@@ -493,6 +491,7 @@ if [[ $# -eq 1 ]]; then
|
||||
esac
|
||||
fi
|
||||
|
||||
|
||||
# always add the '-v level' option, unless level is empty, to the set of options passed to the md2html.sh tool
|
||||
#
|
||||
if [[ -n $V_FLAG ]]; then
|
||||
@@ -500,6 +499,7 @@ if [[ -n $V_FLAG ]]; then
|
||||
TOOL_OPTION+=("$V_FLAG")
|
||||
fi
|
||||
|
||||
|
||||
# always add the '-t tagline' option, unless tagline is empty, to the set of options passed to the md2html.sh tool
|
||||
#
|
||||
if [[ -n $TAGLINE ]]; then
|
||||
@@ -507,16 +507,19 @@ if [[ -n $TAGLINE ]]; then
|
||||
TOOL_OPTION+=("$TAGLINE")
|
||||
fi
|
||||
|
||||
|
||||
# always add the '-U URL' for the top level status.html file
|
||||
#
|
||||
TOOL_OPTION+=("-U")
|
||||
TOOL_OPTION+=("$SITE_URL/status.html")
|
||||
|
||||
|
||||
# always add the '-D docroot/' for the top level status.html file
|
||||
#
|
||||
TOOL_OPTION+=("-D")
|
||||
TOOL_OPTION+=("$DOCROOT_SLASH")
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -537,6 +540,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -560,21 +564,51 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
# verify that the md2html tool is executable
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
if [[ ! -d $BIN_PATH ]]; then
|
||||
echo "$0: ERROR: bin is not a directory under topdir: $BIN_PATH" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
|
||||
# verify that the bin/md2html.sh tool is executable
|
||||
#
|
||||
export MD2HTML_SH="$BIN_DIR/md2html.sh"
|
||||
if [[ ! -e $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: md2html.sh does not exist: $MD2HTML_SH" 1>&2
|
||||
echo "$0: ERROR: bin/md2html.sh does not exist: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: md2html.sh is not a regular file: $MD2HTML_SH" 1>&2
|
||||
echo "$0: ERROR: bin/md2html.sh is not a regular file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: md2html.sh is not an executable file: $MD2HTML_SH" 1>&2
|
||||
echo "$0: ERROR: bin/md2html.sh is not an executable file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that the bin/jval-wrapper.sh tool is executable
|
||||
#
|
||||
JVAL_WRAPPER="$BIN_DIR/jval-wrapper.sh"
|
||||
if [[ ! -e $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh does not exist: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh is not a regular file: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh is not an executable file: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify readable non-empty news.md file
|
||||
#
|
||||
export NEWS_MD="news.md"
|
||||
@@ -595,6 +629,7 @@ if [[ ! -s $NEWS_MD ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# verify readable non-empty status.json file
|
||||
#
|
||||
export STATUS_JSON="status.json"
|
||||
@@ -615,6 +650,7 @@ if [[ ! -s $STATUS_JSON ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# verify readable non-empty status.md file
|
||||
#
|
||||
export STATUS_MD="status.md"
|
||||
@@ -635,10 +671,12 @@ if [[ ! -s $STATUS_MD ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# note status.html file
|
||||
#
|
||||
export STATUS_HTML="status.html"
|
||||
|
||||
|
||||
# verify we have a non-empty readable .top file
|
||||
#
|
||||
export TOP_FILE=".top"
|
||||
@@ -659,6 +697,7 @@ if [[ ! -s $TOP_FILE ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have an inc subdirectory
|
||||
#
|
||||
export INC_PATH="$TOPDIR/inc"
|
||||
@@ -668,6 +707,7 @@ if [[ ! -d $INC_PATH ]]; then
|
||||
fi
|
||||
export INC_DIR="inc"
|
||||
|
||||
|
||||
# verify that we have an next subdirectory
|
||||
#
|
||||
export NEXT_PATH="$TOPDIR/next"
|
||||
@@ -677,6 +717,7 @@ if [[ ! -d $NEXT_PATH ]]; then
|
||||
fi
|
||||
export NEXT_DIR="next"
|
||||
|
||||
|
||||
# determine how we can determine the file modification time in W3C Datetime format:
|
||||
#
|
||||
# https://www.w3.org/TR/NOTE-datetime
|
||||
@@ -734,6 +775,7 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# print running info if verbose
|
||||
#
|
||||
# If -v 3 or higher, print exported variables in order that they were exported.
|
||||
@@ -746,13 +788,10 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: TOPDIR=$TOPDIR" 1>&2
|
||||
echo "$0: debug[3]: DOCROOT_SLASH=$DOCROOT_SLASH" 1>&2
|
||||
echo "$0: debug[3]: TAGLINE=$TAGLINE" 1>&2
|
||||
echo "$0: debug[3]: MD2HTML_SH=$MD2HTML_SH" 1>&2
|
||||
echo "$0: debug[3]: REPO_TOP_URL=$REPO_TOP_URL" 1>&2
|
||||
echo "$0: debug[3]: REPO_URL=$REPO_URL" 1>&2
|
||||
echo "$0: debug[3]: SITE_URL=$SITE_URL" 1>&2
|
||||
echo "$0: debug[3]: JPARSE_TOOL=$JPARSE_TOOL" 1>&2
|
||||
echo "$0: debug[3]: STAT_TOOL=$STAT_TOOL" 1>&2
|
||||
echo "$0: debug[3]: LS_TOOL=$LS_TOOL" 1>&2
|
||||
echo "$0: debug[3]: IOCCC_STATUS_VERSION=$IOCCC_STATUS_VERSION" 1>&2
|
||||
echo "$0: debug[3]: NOOP=$NOOP" 1>&2
|
||||
echo "$0: debug[3]: DO_NOT_PROCESS=$DO_NOT_PROCESS" 1>&2
|
||||
@@ -761,9 +800,16 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: TOOL_OPTION[$index]=${TOOL_OPTION[$index]}" 1>&2
|
||||
done
|
||||
echo "$0: debug[3]: MODTIME_METHOD=$MODTIME_METHOD" 1>&2
|
||||
echo "$0: debug[3]: STAT_TOOL=$STAT_TOOL" 1>&2
|
||||
echo "$0: debug[3]: LS_TOOL=$LS_TOOL" 1>&2
|
||||
echo "$0: debug[3]: IOCCC_STATUS_VERSION=$IOCCC_STATUS_VERSION" 1>&2
|
||||
echo "$0: debug[3]: CONTEST_STATUS=$CONTEST_STATUS" 1>&2
|
||||
echo "$0: debug[3]: REPO_NAME=$REPO_NAME" 1>&2
|
||||
echo "$0: debug[3]: CD_FAILED=$CD_FAILED" 1>&2
|
||||
echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2
|
||||
echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2
|
||||
echo "$0: debug[3]: MD2HTML_SH=$MD2HTML_SH" 1>&2
|
||||
echo "$0: debug[3]: JVAL_WRAPPER=$JVAL_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: NEWS_MD=$NEWS_MD" 1>&2
|
||||
echo "$0: debug[3]: STATUS_JSON=$STATUS_JSON" 1>&2
|
||||
echo "$0: debug[3]: STATUS_MD=$STATUS_MD" 1>&2
|
||||
@@ -775,6 +821,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: NEXT_DIR=$NEXT_DIR" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# validate JSON in status.json
|
||||
#
|
||||
"$JPARSE_TOOL" -q "$STATUS_JSON"
|
||||
@@ -786,18 +833,11 @@ fi
|
||||
|
||||
# obtain contest_status if CONTEST_STATUS was not set in the arg
|
||||
#
|
||||
# XXX - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XXX
|
||||
# XXX - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - XXX
|
||||
# XXX - until we have the jnamval command, we must FAKE PARSE the author/author_handle.json file - XXX
|
||||
# XXX - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - XXX
|
||||
# XXX - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XXX
|
||||
#
|
||||
if [[ -z $CONTEST_STATUS ]]; then
|
||||
|
||||
# obtain the contest_status from status.json
|
||||
#
|
||||
CONTEST_STATUS=$(grep '"contest_status"[[:space:]]*:[[:space:]]*"' "$STATUS_JSON" |
|
||||
sed -e 's/^.*:[[:space:]]*"//' -e 's/",*//')
|
||||
CONTEST_STATUS=$("$JVAL_WRAPPER" -w -b "$STATUS_JSON" '$..contest_status')
|
||||
if [[ -z $CONTEST_STATUS ]]; then
|
||||
echo "$0: ERROR: cannot determine contest_status from status.json: $STATUS_JSON" 1>&2
|
||||
exit 1
|
||||
@@ -806,13 +846,13 @@ if [[ -z $CONTEST_STATUS ]]; then
|
||||
# validate and normalize the contest_status from status.json
|
||||
#
|
||||
case "$CONTEST_STATUS" in
|
||||
p|pending) CONTEST_STATUS="pending"
|
||||
pending) CONTEST_STATUS="pending"
|
||||
;;
|
||||
o|open) CONTEST_STATUS="open"
|
||||
open) CONTEST_STATUS="open"
|
||||
;;
|
||||
j|judging) CONTEST_STATUS="judging"
|
||||
judging) CONTEST_STATUS="judging"
|
||||
;;
|
||||
c|closed) CONTEST_STATUS="closed"
|
||||
closed) CONTEST_STATUS="closed"
|
||||
;;
|
||||
*) echo "$0: ERROR: unexpected status from $status.json: $CONTEST_STATUS" 1>&2
|
||||
echo 1>&2
|
||||
@@ -822,6 +862,7 @@ if [[ -z $CONTEST_STATUS ]]; then
|
||||
esac
|
||||
fi
|
||||
|
||||
|
||||
# determine the rules.md markdown file
|
||||
#
|
||||
export RULES_MD="$NEXT_DIR/rules.md"
|
||||
@@ -843,6 +884,7 @@ if [[ ! -s $RULES_MD ]]; then
|
||||
fi
|
||||
export RULES_HTML="$NEXT_DIR/rules.html"
|
||||
|
||||
|
||||
# determine the rules.md markdown file
|
||||
#
|
||||
export GUIDELINES_MD="$NEXT_DIR/guidelines.md"
|
||||
@@ -864,6 +906,7 @@ if [[ ! -s $GUIDELINES_MD ]]; then
|
||||
fi
|
||||
export GUIDELINES_HTML="$NEXT_DIR/guidelines.html"
|
||||
|
||||
|
||||
# determine the rules hdr file
|
||||
#
|
||||
export RULES_HDR="$INC_PATH/rules.$CONTEST_STATUS.hdr"
|
||||
@@ -884,6 +927,7 @@ if [[ ! -s $RULES_HDR ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# determine the guidelines hdr file
|
||||
#
|
||||
export GUIDELINES_HDR="$INC_PATH/guidelines.$CONTEST_STATUS.hdr"
|
||||
@@ -904,6 +948,7 @@ if [[ ! -s $GUIDELINES_HDR ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# -N stops early before any processing is performed
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -913,6 +958,7 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary status.json file
|
||||
#
|
||||
export TMP_STATUS_JSON=".tmp.$NAME.STATUS_JSON.$$.tmp"
|
||||
@@ -935,6 +981,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary status.json file is not used: $TMP_STATUS_JSON" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary rules.md file
|
||||
#
|
||||
export TMP_RULES_MD=".tmp.$NAME.RULES_MD.$$.tmp"
|
||||
@@ -957,6 +1004,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary rules.md file is not used: $TMP_RULES_MD" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary guidelines.md file
|
||||
#
|
||||
export TMP_GUIDELINES_MD=".tmp.$NAME.GUIDELINES_MD.$$.tmp"
|
||||
@@ -979,6 +1027,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary guidelines.md file is not used: $TMP_GUIDELINES_MD" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# generate the temporary status.json file
|
||||
#
|
||||
# In this stage, we use the date of the actual status.json file.
|
||||
@@ -1069,6 +1118,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary status.json file is NOT written into: $TMP_STATUS_JSON" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# use the md2html.sh tool to form the status.html file, unless -n
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -1095,6 +1145,7 @@ elif [[ $V_FLAG -ge 5 ]]; then
|
||||
"status.md $STATUS_HTML" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# update rules.md
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -1179,6 +1230,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, rules.md was not updated: $RULES_MD" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# update guidelines.md
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -1263,6 +1315,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, guidelines.md was not updated: $GUIDELINES_MD" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# file cleanup
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -1271,6 +1324,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, disabled: rm -f -- $TMP_STATUS_JSON" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
exit 0
|
||||
+49
-30
@@ -36,6 +36,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -79,6 +80,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -91,6 +93,7 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.4.9 2024-08-11"
|
||||
@@ -111,8 +114,6 @@ fi
|
||||
export TOPDIR
|
||||
export DOCROOT_SLASH="./"
|
||||
export TAGLINE="bin/$NAME"
|
||||
export MD2HTML_SH="bin/md2html.sh"
|
||||
export PANDOC_WRAPPER="bin/pandoc-wrapper.sh"
|
||||
export REPO_TOP_URL="https://github.com/ioccc-src/temp-test-ioccc"
|
||||
# GitHub puts individual files under the "blob/master" sub-directory.
|
||||
export REPO_URL="$REPO_TOP_URL/blob/master"
|
||||
@@ -147,15 +148,17 @@ export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
export EXIT_CODE="0"
|
||||
|
||||
|
||||
# clear options we will add to tools
|
||||
#
|
||||
unset TOOL_OPTION
|
||||
declare -ag TOOL_OPTION
|
||||
|
||||
|
||||
# usage
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
[-t tagline] [-T md2html.sh] [-p tool] [file...]
|
||||
[-t tagline] [file...]
|
||||
|
||||
-h print help message and exit
|
||||
-v level set verbosity level (def level: 0)
|
||||
@@ -173,17 +176,13 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
|
||||
-t tagline string to write about the tool that formed the markdown content (def: $TAGLINE)
|
||||
NOTE: 'tagline' may be enclosed within, but may NOT contain an internal single-quote, or double-quote.
|
||||
-T md2html.sh run 'markdown to html tool' to convert markdown into HTML (def: $MD2HTML_SH)
|
||||
|
||||
-p tool run 'pandoc wrapper tool' (not pandoc path) during HTML phase number 21 (def: use $PANDOC_WRAPPER)
|
||||
NOTE: The '-p tool' is passed as leading options on tool command lines.
|
||||
|
||||
-w site_url Base URL of the website (def: $SITE_URL)
|
||||
NOTE: The '-w site_url' is passed as leading options on tool command lines.
|
||||
|
||||
NOTE: The '-v level' is passed as initial command line options to the 'markdown to html tool' (md2html.sh).
|
||||
The 'tagline' is passed as '-t tagline' to the 'markdown to html tool' (md2html.sh), after the '-v level'.
|
||||
Any '-T md2html.sh', '-p tool', '-P pandoc_opts', '-U top_url'
|
||||
Any '-P pandoc_opts', '-U top_url'
|
||||
are passed to the 'markdown to html tool' (md2html.sh), and will be before any command line arguments.
|
||||
|
||||
Exit codes:
|
||||
@@ -199,9 +198,10 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNt:T:p:w: flag; do
|
||||
while getopts :hv:Vd:D:nNt:w: flag; do
|
||||
case "$flag" in
|
||||
h) echo "$USAGE" 1>&2
|
||||
exit 2
|
||||
@@ -250,14 +250,6 @@ while getopts :hv:Vd:D:nNt:T:p:w: flag; do
|
||||
TAGLINE="$OPTARG"
|
||||
# -t tagline always added after arg parsing
|
||||
;;
|
||||
T) MD2HTML_SH="$OPTARG"
|
||||
TOOL_OPTION+=("-T")
|
||||
TOOL_OPTION+=("$MD2HTML_SH")
|
||||
;;
|
||||
p) PANDOC_WRAPPER="$OPTARG"
|
||||
TOOL_OPTION+=("-p")
|
||||
TOOL_OPTION+=("$PANDOC_WRAPPER")
|
||||
;;
|
||||
w) SITE_URL="$OPTARG"
|
||||
TOOL_OPTION+=("-w")
|
||||
TOOL_OPTION+=("$SITE_URL")
|
||||
@@ -279,7 +271,7 @@ while getopts :hv:Vd:D:nNt:T:p:w: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# remove the options
|
||||
#
|
||||
shift $(( OPTIND - 1 ));
|
||||
@@ -289,8 +281,9 @@ shift $(( OPTIND - 1 ));
|
||||
if [[ $V_FLAG -ge 5 ]]; then
|
||||
echo "$0: debug[5]: file argument count: $#" 1>&2
|
||||
fi
|
||||
|
||||
#
|
||||
# allow specifying specific files to generate
|
||||
#
|
||||
FILE_COUNT="$#"
|
||||
while [[ $# -ne 0 ]]; do
|
||||
for (( index=0; index < ${#TOP_MD_SET[@]}; index++ )); do
|
||||
@@ -304,12 +297,13 @@ if [[ "$FILE_COUNT" != 0 && ${#TOP_MD_SELECT_SET[@]} = 0 ]]; then
|
||||
echo "$0: ERROR: no select files specified are in allowed set" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
|
||||
#
|
||||
if [[ $# -ne 0 ]]; then
|
||||
echo "$0: ERROR: expected 0 args, found: $#" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
|
||||
|
||||
# always add the '-v level' option, unless level is empty, to the set of options passed to the md2html.sh tool
|
||||
#
|
||||
if [[ -n $V_FLAG ]]; then
|
||||
@@ -317,6 +311,7 @@ if [[ -n $V_FLAG ]]; then
|
||||
TOOL_OPTION+=("$V_FLAG")
|
||||
fi
|
||||
|
||||
|
||||
# always add the '-t tagline' option, unless tagline is empty, to the set of options passed to the md2html.sh tool
|
||||
#
|
||||
if [[ -n $TAGLINE ]]; then
|
||||
@@ -324,11 +319,13 @@ if [[ -n $TAGLINE ]]; then
|
||||
TOOL_OPTION+=("$TAGLINE")
|
||||
fi
|
||||
|
||||
|
||||
# always add the '-D docroot/' for the top level files
|
||||
#
|
||||
TOOL_OPTION+=("-D")
|
||||
TOOL_OPTION+=("$DOCROOT_SLASH")
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -349,6 +346,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -372,6 +370,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have an author subdirectory
|
||||
#
|
||||
export AUTHOR_PATH="$TOPDIR/author"
|
||||
@@ -381,6 +380,7 @@ if [[ ! -d $AUTHOR_PATH ]]; then
|
||||
fi
|
||||
export AUTHOR_DIR="author"
|
||||
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
@@ -390,35 +390,51 @@ if [[ ! -d $BIN_PATH ]]; then
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# verify that the md2html tool is executable
|
||||
|
||||
# verify that the bin/md2html.sh tool is executable
|
||||
#
|
||||
export MD2HTML_SH="$BIN_DIR/md2html.sh"
|
||||
if [[ ! -e $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: md2html.sh does not exist: $MD2HTML_SH" 1>&2
|
||||
echo "$0: ERROR: bin/md2html.sh does not exist: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: md2html.sh is not a regular file: $MD2HTML_SH" 1>&2
|
||||
echo "$0: ERROR: bin/md2html.sh is not a regular file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: md2html.sh is not an executable file: $MD2HTML_SH" 1>&2
|
||||
echo "$0: ERROR: bin/md2html.sh is not an executable file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that the bin/pandoc-wrapper.sh tool is executable
|
||||
#
|
||||
export PANDOC_WRAPPER="$BIN_DIR/pandoc-wrapper.sh"
|
||||
if [[ ! -e $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh does not exist: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not a regular file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not an executable file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# find the location tool
|
||||
#
|
||||
LOCATION_TOOL=$(type -P location)
|
||||
if [[ -z $LOCATION_TOOL ]]; then
|
||||
# guess we have a location tool in bin
|
||||
#
|
||||
LOCATION_TOOL="$BIN_DIR/location"
|
||||
fi
|
||||
if [[ ! -x $LOCATION_TOOL ]]; then
|
||||
echo "$0: ERROR: cannot find the location executable" 1>&2
|
||||
echo "$0: notice: location tool comes from this repo: https://github.com/ioccc-src/mkiocccentry" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# print running info if verbose
|
||||
#
|
||||
# If -v 3 or higher, print exported variables in order that they were exported.
|
||||
@@ -431,7 +447,6 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: TOPDIR=$TOPDIR" 1>&2
|
||||
echo "$0: debug[3]: DOCROOT_SLASH=$DOCROOT_SLASH" 1>&2
|
||||
echo "$0: debug[3]: TAGLINE=$TAGLINE" 1>&2
|
||||
echo "$0: debug[3]: MD2HTML_SH=$MD2HTML_SH" 1>&2
|
||||
echo "$0: debug[3]: PANDOC_WRAPPER=$PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: REPO_TOP_URL=$REPO_TOP_URL" 1>&2
|
||||
echo "$0: debug[3]: REPO_URL=$REPO_URL" 1>&2
|
||||
@@ -456,8 +471,10 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: AUTHOR_DIR=$AUTHOR_DIR" 1>&2
|
||||
echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2
|
||||
echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2
|
||||
echo "$0: debug[3]: MD2HTML_SH=$MD2HTML_SH" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# -N stops early before any processing is performed
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -467,6 +484,7 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# process the entire markdown set
|
||||
#
|
||||
if (( ${#TOP_MD_SELECT_SET[@]} )); then
|
||||
@@ -629,6 +647,7 @@ else
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
if [[ $EXIT_CODE -ne 0 ]]; then
|
||||
|
||||
+79
-25
@@ -28,6 +28,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -71,6 +72,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -83,9 +85,10 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.1.2 2024-08-05"
|
||||
export VERSION="1.2 2024-08-17"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -103,21 +106,22 @@ fi
|
||||
export TOPDIR
|
||||
export DOCROOT_SLASH="../../"
|
||||
export TAGLINE="bin/$NAME"
|
||||
export MD2HTML_SH="bin/md2html.sh"
|
||||
export REPO_TOP_URL="https://github.com/ioccc-src/temp-test-ioccc"
|
||||
# GitHub puts individual files under the "blob/master" sub-directory.
|
||||
export REPO_URL="$REPO_TOP_URL/blob/master"
|
||||
export SITE_URL="https://ioccc-src.github.io/temp-test-ioccc"
|
||||
|
||||
|
||||
# clear options we will add to tools
|
||||
#
|
||||
unset TOOL_OPTION
|
||||
declare -ag TOOL_OPTION
|
||||
|
||||
|
||||
# set usage message
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N]
|
||||
[-t tagline] [-T md2html.sh] [-w site_url]
|
||||
[-Q] [-t tagline] [-w site_url]
|
||||
YYYY [more_options]
|
||||
|
||||
-h print help message and exit
|
||||
@@ -131,8 +135,9 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N]
|
||||
-n go thru the actions, but do not update any files (def: do the action)
|
||||
-N do not process file, just parse arguments and ignore the file (def: process the file)
|
||||
|
||||
-Q quick mode, do not run $MD2HTML_SH unless markdown is out of date (def: do)
|
||||
|
||||
-t tagline string to write about the tool that formed the markdown content (def: $TAGLINE)
|
||||
-T md2html.sh run 'markdown to html tool' to convert markdown into HTML (def: $MD2HTML_SH)
|
||||
|
||||
-w site_url Base URL of the website (def: $SITE_URL)
|
||||
NOTE: The '-w site_url' is passed as leading options on tool command lines.
|
||||
@@ -153,14 +158,17 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# setup
|
||||
#
|
||||
export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
export QUICK_MODE=
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNt:T:w: flag; do
|
||||
while getopts :hv:Vd:D:nNQt:w: flag; do
|
||||
case "$flag" in
|
||||
h) echo "$USAGE" 1>&2
|
||||
exit 2
|
||||
@@ -189,6 +197,8 @@ while getopts :hv:Vd:D:nNt:T:w: flag; do
|
||||
;;
|
||||
N) DO_NOT_PROCESS="-N"
|
||||
;;
|
||||
Q) QUICK_MODE="-Q"
|
||||
;;
|
||||
t) # parse -t tagline
|
||||
case "$OPTARG" in
|
||||
*"'"*)
|
||||
@@ -208,10 +218,6 @@ while getopts :hv:Vd:D:nNt:T:w: flag; do
|
||||
TAGLINE="$OPTARG"
|
||||
# -t tagline is always added further down
|
||||
;;
|
||||
T) MD2HTML_SH="$OPTARG"
|
||||
TOOL_OPTION+=("-T")
|
||||
TOOL_OPTION+=("$MD2HTML_SH")
|
||||
;;
|
||||
w) SITE_URL="$OPTARG"
|
||||
TOOL_OPTION+=("-w")
|
||||
TOOL_OPTION+=("$SITE_URL")
|
||||
@@ -233,7 +239,7 @@ while getopts :hv:Vd:D:nNt:T:w: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# parse the command line arguments
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -267,6 +273,7 @@ if [[ -z $YYYY ]]; then
|
||||
exit 3
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -287,6 +294,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -310,6 +318,34 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
if [[ ! -d $BIN_PATH ]]; then
|
||||
echo "$0: ERROR: bin is not a directory under topdir: $BIN_PATH" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
|
||||
# verify that the bin/md2html.sh tool is executable
|
||||
#
|
||||
export MD2HTML_SH="$BIN_DIR/md2html.sh"
|
||||
if [[ ! -e $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh does not exist: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not a regular file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not an executable file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that YYYY is an IOCCC year directory
|
||||
#
|
||||
if [[ ! -e $YYYY ]]; then
|
||||
@@ -325,6 +361,7 @@ if [[ ! -r $YYYY ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# verify that YYYY has a non-empty readable .year file
|
||||
#
|
||||
export DOT_YEAR="$YYYY/.year"
|
||||
@@ -345,6 +382,7 @@ if [[ ! -s $DOT_YEAR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# verify that YYYY/README.md is a non-empty readable file
|
||||
#
|
||||
export README_FILE="$YYYY/README.md"
|
||||
@@ -365,26 +403,13 @@ if [[ ! -s $README_FILE ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify that the md2html.sh is an executable file
|
||||
#
|
||||
if [[ ! -e $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: md2html.sh does not exist: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: md2html.sh is not a regular file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: md2html.sh is not an executable file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# always add -t tagline
|
||||
#
|
||||
TOOL_OPTION+=("-t")
|
||||
TOOL_OPTION+=("$TAGLINE")
|
||||
|
||||
|
||||
# parameter debugging
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -395,7 +420,6 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: TOPDIR=$TOPDIR" 1>&2
|
||||
echo "$0: debug[3]: DOCROOT_SLASH=$DOCROOT_SLASH" 1>&2
|
||||
echo "$0: debug[3]: TAGLINE=$TAGLINE" 1>&2
|
||||
echo "$0: debug[3]: MD2HTML_SH=$MD2HTML_SH" 1>&2
|
||||
echo "$0: debug[3]: REPO_TOP_URL=$REPO_TOP_URL" 1>&2
|
||||
echo "$0: debug[3]: REPO_URL=$REPO_URL" 1>&2
|
||||
echo "$0: debug[3]: SITE_URL=$SITE_URL" 1>&2
|
||||
@@ -404,13 +428,18 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
done
|
||||
echo "$0: debug[3]: NOOP=$NOOP" 1>&2
|
||||
echo "$0: debug[3]: DO_NOT_PROCESS=$DO_NOT_PROCESS" 1>&2
|
||||
echo "$0: debug[3]: QUICK_MODE=$QUICK_MODE" 1>&2
|
||||
echo "$0: debug[3]: YYYY=$YYYY" 1>&2
|
||||
echo "$0: debug[3]: REPO_NAME=$REPO_NAME" 1>&2
|
||||
echo "$0: debug[3]: CD_FAILED=$CD_FAILED" 1>&2
|
||||
echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2
|
||||
echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2
|
||||
echo "$0: debug[3]: MD2HTML_SH=$MD2HTML_SH" 1>&2
|
||||
echo "$0: debug[3]: DOT_YEAR=$DOT_YEAR" 1>&2
|
||||
echo "$0: debug[3]: README_FILE=$README_FILE" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# If -N, time to exit
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -420,10 +449,24 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# case: -Q (quick mode)
|
||||
#
|
||||
# Do nothing if authors.html is newer than all author/author_handle.json files.
|
||||
#
|
||||
if [[ -n $QUICK_MODE ]]; then
|
||||
if [[ $YYYY/index.html -nt $YYYY/README.md ]]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# form the YYYY index.html unless -n
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
|
||||
# possibly update YYYY index.html
|
||||
#
|
||||
if [[ $V_FLAG -ge 1 ]]; then
|
||||
echo "$0: debug[1]: about to run: $MD2HTML_SH -U $SITE_URL/$YYYY/index.html ${TOOL_OPTION[*]}" \
|
||||
"-m $YYYY/README.md -- $YYYY/README.md $YYYY/index.html" 1>&2
|
||||
@@ -437,6 +480,16 @@ if [[ -z $NOOP ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# case -Q: (quick mode)
|
||||
#
|
||||
# If we are here, then the early quick mode test indicated that the prerequisite files are newer.
|
||||
# We will force the authors.html file to be touched so that a later run with -Q will quickly exit.
|
||||
# We do this because by default, the md2html.sh tool does not modify the target HTML unless it was modified.
|
||||
#
|
||||
if [[ -n $QUICK_MODE ]]; then
|
||||
touch "$YYYY/index.html"
|
||||
fi
|
||||
|
||||
# report disabled by -n
|
||||
#
|
||||
elif [[ $V_FLAG -ge 5 ]]; then
|
||||
@@ -444,6 +497,7 @@ elif [[ $V_FLAG -ge 5 ]]; then
|
||||
"$YYYY/README.md $YYYY/index.html" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
exit 0
|
||||
+86
-28
@@ -28,6 +28,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -71,6 +72,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -83,9 +85,10 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.3.7 2024-08-05"
|
||||
export VERSION="1.4 2024-08-17"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -115,8 +118,6 @@ if [[ ! -x $FMT_TOOL ]]; then
|
||||
fi
|
||||
export DOCROOT_SLASH="./"
|
||||
export TAGLINE="bin/$NAME"
|
||||
export MD2HTML_SH="bin/md2html.sh"
|
||||
export PANDOC_WRAPPER="bin/pandoc-wrapper.sh"
|
||||
export REPO_TOP_URL="https://github.com/ioccc-src/temp-test-ioccc"
|
||||
# GitHub puts individual files under the "blob/master" sub-directory.
|
||||
export REPO_URL="$REPO_TOP_URL/blob/master"
|
||||
@@ -126,15 +127,17 @@ export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
export EXIT_CODE="0"
|
||||
|
||||
|
||||
# clear options we will add to tools
|
||||
#
|
||||
unset TOOL_OPTION
|
||||
declare -ag TOOL_OPTION
|
||||
|
||||
|
||||
# usage
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
[-t tagline] [-T md2html.sh] [-p tool]
|
||||
[-t tagline] [-w site_url]
|
||||
|
||||
-h print help message and exit
|
||||
-v level set verbosity level (def level: 0)
|
||||
@@ -152,17 +155,13 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
|
||||
-t tagline string to write about the tool that formed the markdown content (def: $TAGLINE)
|
||||
NOTE: 'tagline' may be enclosed within, but may NOT contain an internal single-quote, or double-quote.
|
||||
-T md2html.sh run 'markdown to html tool' to convert markdown into HTML (def: $MD2HTML_SH)
|
||||
|
||||
-p tool run 'pandoc wrapper tool' (not pandoc path) during HTML phase number 21 (def: use $PANDOC_WRAPPER)
|
||||
NOTE: The '-p tool' is passed as leading options on tool command lines.
|
||||
|
||||
-w site_url Base URL of the website (def: $SITE_URL)
|
||||
NOTE: The '-w site_url' is passed as leading options on tool command lines.
|
||||
|
||||
NOTE: The '-v level' is passed as initial command line options to the 'markdown to html tool' (md2html.sh).
|
||||
The 'tagline' is passed as '-t tagline' to the 'markdown to html tool' (md2html.sh), after the '-v level'.
|
||||
Any '-T md2html.sh', '-p tool', '-P pandoc_opts', '-U top_url'
|
||||
Any '-P pandoc_opts', '-U top_url'
|
||||
are passed to the 'markdown to html tool' (md2html.sh), and will be before any command line arguments.
|
||||
|
||||
Exit codes:
|
||||
@@ -178,16 +177,11 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# output_award
|
||||
#
|
||||
# Write the award name to standard output (stdout)
|
||||
#
|
||||
# XXX - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XXX
|
||||
# XXX - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - XXX
|
||||
# XXX - until we have the jnamval command, we must FAKE PARSE the .entry.json file - XXX
|
||||
# XXX - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - XXX
|
||||
# XXX - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XXX
|
||||
#
|
||||
# usage:
|
||||
# output_award YYYY/dir/.entry.json
|
||||
#
|
||||
@@ -222,7 +216,7 @@ function output_award
|
||||
|
||||
# obtain the award string
|
||||
#
|
||||
AWARD_STRING=$(grep -F '"award" : "' "$ENTRY_JSON_PATH" | sed -e 's/^.*"award" : "//' -e 's/",//')
|
||||
AWARD_STRING=$("$JVAL_WRAPPER" -w -b "$ENTRY_JSON_PATH" '$..award')
|
||||
if [[ -z $AWARD_STRING ]]; then
|
||||
echo "$0: ERROR: in output_award: no award found in .entry.json file: $ENTRY_JSON_PATH" 1>&2
|
||||
return 5
|
||||
@@ -231,6 +225,7 @@ function output_award
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# output_ordinal
|
||||
#
|
||||
# Write the numerical ordinal form of a non-negative integer to standard output (stdout)
|
||||
@@ -292,9 +287,10 @@ function output_ordinal
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNt:T:p:w: flag; do
|
||||
while getopts :hv:Vd:D:nNt:w: flag; do
|
||||
case "$flag" in
|
||||
h) echo "$USAGE" 1>&2
|
||||
exit 2
|
||||
@@ -343,14 +339,6 @@ while getopts :hv:Vd:D:nNt:T:p:w: flag; do
|
||||
TAGLINE="$OPTARG"
|
||||
# -t tagline always added after arg parsing
|
||||
;;
|
||||
T) MD2HTML_SH="$OPTARG"
|
||||
TOOL_OPTION+=("-T")
|
||||
TOOL_OPTION+=("$MD2HTML_SH")
|
||||
;;
|
||||
p) PANDOC_WRAPPER="$OPTARG"
|
||||
TOOL_OPTION+=("-p")
|
||||
TOOL_OPTION+=("$PANDOC_WRAPPER")
|
||||
;;
|
||||
w) SITE_URL="$OPTARG"
|
||||
TOOL_OPTION+=("-w")
|
||||
TOOL_OPTION+=("$SITE_URL")
|
||||
@@ -372,7 +360,7 @@ while getopts :hv:Vd:D:nNt:T:p:w: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# remove the options
|
||||
#
|
||||
shift $(( OPTIND - 1 ));
|
||||
@@ -388,6 +376,7 @@ if [[ $# -ne 0 ]]; then
|
||||
exit 3
|
||||
fi
|
||||
|
||||
|
||||
# always add the '-v level' option, unless level is empty, to the set of options passed to the md2html.sh tool
|
||||
#
|
||||
if [[ -n $V_FLAG ]]; then
|
||||
@@ -395,6 +384,7 @@ if [[ -n $V_FLAG ]]; then
|
||||
TOOL_OPTION+=("$V_FLAG")
|
||||
fi
|
||||
|
||||
|
||||
# always add the '-t tagline' option, unless tagline is empty, to the set of options passed to the md2html.sh tool
|
||||
#
|
||||
if [[ -n $TAGLINE ]]; then
|
||||
@@ -402,16 +392,19 @@ if [[ -n $TAGLINE ]]; then
|
||||
TOOL_OPTION+=("$TAGLINE")
|
||||
fi
|
||||
|
||||
|
||||
# always add the '-U URL' for the top level location.html file
|
||||
#
|
||||
TOOL_OPTION+=("-U")
|
||||
TOOL_OPTION+=("$SITE_URL/years.html")
|
||||
|
||||
|
||||
# always add the '-D docroot/' for the top level location.html file
|
||||
#
|
||||
TOOL_OPTION+=("-D")
|
||||
TOOL_OPTION+=("$DOCROOT_SLASH")
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -432,6 +425,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -455,6 +449,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
@@ -464,6 +459,58 @@ if [[ ! -d $BIN_PATH ]]; then
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
|
||||
# verify that the bin/md2html.sh tool is executable
|
||||
#
|
||||
export MD2HTML_SH="$BIN_DIR/md2html.sh"
|
||||
if [[ ! -e $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh does not exist: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not a regular file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not an executable file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that the bin/pandoc-wrapper.sh tool is executable
|
||||
#
|
||||
export PANDOC_WRAPPER="$BIN_DIR/pandoc-wrapper.sh"
|
||||
if [[ ! -e $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh does not exist: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not a regular file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not an executable file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that the bin/jval-wrapper.sh tool is executable
|
||||
#
|
||||
JVAL_WRAPPER="$BIN_DIR/jval-wrapper.sh"
|
||||
if [[ ! -e $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh does not exist: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh is not a regular file: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh is not an executable file: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify we have a non-empty readable .top file
|
||||
#
|
||||
export TOP_FILE=".top"
|
||||
@@ -484,6 +531,7 @@ if [[ ! -s $TOP_FILE ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# verify that the md2html tool is executable
|
||||
#
|
||||
if [[ ! -e $MD2HTML_SH ]]; then
|
||||
@@ -499,10 +547,12 @@ if [[ ! -x $MD2HTML_SH ]]; then
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# note years.html file
|
||||
#
|
||||
export YEARS_HTML="years.html"
|
||||
|
||||
|
||||
# print running info if verbose
|
||||
#
|
||||
# If -v 3 or higher, print exported variables in order that they were exported.
|
||||
@@ -517,8 +567,6 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: FMT_TOOL=$FMT_TOOL" 1>&2
|
||||
echo "$0: debug[3]: DOCROOT_SLASH=$DOCROOT_SLASH" 1>&2
|
||||
echo "$0: debug[3]: TAGLINE=$TAGLINE" 1>&2
|
||||
echo "$0: debug[3]: MD2HTML_SH=$MD2HTML_SH" 1>&2
|
||||
echo "$0: debug[3]: PANDOC_WRAPPER=$PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: REPO_TOP_URL=$REPO_TOP_URL" 1>&2
|
||||
echo "$0: debug[3]: REPO_URL=$REPO_URL" 1>&2
|
||||
echo "$0: debug[3]: SITE_URL=$SITE_URL" 1>&2
|
||||
@@ -532,10 +580,14 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: CD_FAILED=$CD_FAILED" 1>&2
|
||||
echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2
|
||||
echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2
|
||||
echo "$0: debug[3]: MD2HTML_SH=$MD2HTML_SH" 1>&2
|
||||
echo "$0: debug[3]: PANDOC_WRAPPER=$PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: JVAL_WRAPPER=$JVAL_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: TOP_FILE=$TOP_FILE" 1>&2
|
||||
echo "$0: debug[3]: YEARS_HTML=$YEARS_HTML" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# -N stops early before any processing is performed
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -545,6 +597,7 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary years markdown file
|
||||
#
|
||||
export TMP_YEARS_MD=".tmp.$NAME.YEARS_MD.$$.tmp"
|
||||
@@ -567,6 +620,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary years markdown file is not used: $TMP_YEARS_MD" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# write All IOCCC years markdown data
|
||||
#
|
||||
{
|
||||
@@ -851,6 +905,7 @@ for YYYY in $("$TAC_TOOL" "$TOP_FILE"); do
|
||||
((--YEAR_COUNT))
|
||||
done
|
||||
|
||||
|
||||
# write year_level links to all the year level tarballs
|
||||
#
|
||||
{
|
||||
@@ -874,6 +929,7 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# use the md2html.sh tool to form a location HTML file, unless -n
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -897,6 +953,7 @@ elif [[ $V_FLAG -ge 5 ]]; then
|
||||
echo "$0: debug[5]: because of -n, did not run: $MD2HTML_SH ${TOOL_OPTION[*]} -- years.md $TMP_YEARS_MD $YEARS_HTML" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# file cleanup
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -905,6 +962,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, disabled: rm -f -- $TMP_YEARS_MD" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
if [[ $EXIT_CODE -ne 0 ]]; then
|
||||
|
||||
+7
-1
@@ -35,6 +35,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -78,6 +79,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -90,6 +92,7 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.0.2 2024-08-08"
|
||||
@@ -100,6 +103,7 @@ export V_FLAG=0
|
||||
JPARSE_TOOL=$(type -P jparse)
|
||||
export JPARSE_TOOL
|
||||
|
||||
|
||||
# Until we have a true jfmt tool, we will use the modified JSONPath.sh
|
||||
#
|
||||
# XXX - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XXX
|
||||
@@ -153,11 +157,13 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# setup
|
||||
#
|
||||
export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:VnNj: flag; do
|
||||
@@ -193,7 +199,7 @@ while getopts :hv:VnNj: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# parse the command line arguments
|
||||
#
|
||||
if [[ $V_FLAG -ge 1 ]]; then
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -75,6 +76,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -87,6 +89,7 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.0.2 2024-08-08"
|
||||
@@ -94,6 +97,7 @@ NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
|
||||
|
||||
# Until we have a true jprint tool, we will use the modified JSONPath.sh
|
||||
#
|
||||
# BTW: A jprint tool might be a special case of a jfmt tool, with a command line
|
||||
@@ -121,6 +125,7 @@ if ! "$JSONPATH_SH" -S -A -T -p >/dev/null 2>&1; then
|
||||
exit 5
|
||||
fi <<< "$FIZZBIN_JSON"
|
||||
|
||||
|
||||
# set usage message
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-n] [-N] [-j JSONPath.sh] [file.json]
|
||||
@@ -148,11 +153,13 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# setup
|
||||
#
|
||||
export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:VnNj: flag; do
|
||||
@@ -188,7 +195,7 @@ while getopts :hv:VnNj: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# parse the command line arguments
|
||||
#
|
||||
if [[ $V_FLAG -ge 1 ]]; then
|
||||
|
||||
+9
-1
@@ -46,6 +46,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -89,6 +90,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -101,6 +103,7 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.0.3 2024-08-11"
|
||||
@@ -108,6 +111,7 @@ NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
|
||||
|
||||
# Until we have a true jval tool, we will use the modified JSONPath.sh
|
||||
#
|
||||
# XXX - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XXX
|
||||
@@ -137,6 +141,7 @@ export PATTERN='$*'
|
||||
unset OPTION
|
||||
declare -ag OPTION
|
||||
|
||||
|
||||
# set usage message
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-n] [-N]
|
||||
@@ -172,11 +177,13 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# setup
|
||||
#
|
||||
export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:VnNwbiuj: flag; do
|
||||
@@ -220,7 +227,7 @@ while getopts :hv:VnNwbiuj: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# parse the command line arguments
|
||||
#
|
||||
if [[ $V_FLAG -ge 1 ]]; then
|
||||
@@ -281,6 +288,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: PATTERN=$PATTERN" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# -N stops early before any processing is performed
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
|
||||
+200
-134
@@ -78,6 +78,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -121,6 +122,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -133,15 +135,17 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# other required bash options
|
||||
#
|
||||
# Requires bash with a version 4.2 or later
|
||||
#
|
||||
shopt -s lastpipe # run last command of a pipeline not executed in the background in the current shell environment
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.5.5 2024-08-05"
|
||||
export VERSION="1.6 2024-08-17"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -164,18 +168,18 @@ if [[ -z "$PERL_TOOL" ]]; then
|
||||
fi
|
||||
export TOPDIR
|
||||
export DOCROOT_SLASH="./"
|
||||
export PANDOC_WRAPPER="bin/pandoc-wrapper.sh"
|
||||
export REPO_TOP_URL="https://github.com/ioccc-src/temp-test-ioccc"
|
||||
# GitHub puts individual files under the "blob/master" sub-directory.
|
||||
export REPO_URL="$REPO_TOP_URL/blob/master"
|
||||
export SITE_URL="https://ioccc-src.github.io/temp-test-ioccc"
|
||||
export URL="#"
|
||||
|
||||
|
||||
# set usage message
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
[-c md2html.cfg] [-H phase=name ..] [-t tagline]
|
||||
[-b tool] [-p tool] [-a tool]
|
||||
[-b tool] [-a tool]
|
||||
[-s token=value ..] [-S] [-o tool ..]
|
||||
[-U url] [-w site_url] [-m mdtag] [-e string ..] [-E exitcode]
|
||||
[match.md] input.md output.html
|
||||
@@ -208,10 +212,6 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
-b tool run 'before tool' during HTML phase number 20 (def: do not output before pandoc wrapper tool)
|
||||
-b . skip HTML phase number 20 (def: do nothing during HTML phase number 20)
|
||||
|
||||
-p tool run 'pandoc wrapper tool' (not pandoc path) during HTML phase number 21 (def: use $PANDOC_WRAPPER)
|
||||
-p . skip HTML phase number 21 (def: do nothing during HTML phase number 21)
|
||||
NOTE: The '-p tool' will be passed as leading options on the -b tool and -a tool command lines.
|
||||
|
||||
-a tool run 'after tool' during HTML phase number 20 (def: do not output after pandoc wrapper tool)
|
||||
-a . skip HTML phase number 22 (def: do nothing during HTML phase number 22)
|
||||
|
||||
@@ -256,10 +256,12 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
##################################
|
||||
# command line parsing functions #
|
||||
##################################
|
||||
|
||||
|
||||
# global_variable_setup - setup global variables
|
||||
#
|
||||
# Call this once at the start of the shell script.
|
||||
@@ -338,7 +340,7 @@ function global_variable_setup
|
||||
unset PHASE_NAME
|
||||
declare -ag PHASE_NAME
|
||||
PHASE_NAME=(top head body topbar header navbar before-content
|
||||
after-content footer bottom)
|
||||
after-content footer bottom)
|
||||
unset HTML_PHASE_NAME
|
||||
declare -Ag HTML_PHASE_NAME
|
||||
for n in "${PHASE_NAME[@]}"; do
|
||||
@@ -351,6 +353,7 @@ function global_variable_setup
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# print_usage - print the usage message, exit code and version information
|
||||
#
|
||||
# Call this to print the usage message, by default to stdout.
|
||||
@@ -366,6 +369,7 @@ function print_usage
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# parse_command_line - parse command line arguments
|
||||
#
|
||||
# You MUST call this function at least once AND after calling global_variable_setup.
|
||||
@@ -412,7 +416,7 @@ function parse_command_line
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:VnNd:D:c:H:t:m:b:p:a:s:So:U:w:e:E: flag; do
|
||||
while getopts :hv:VnNd:D:c:H:t:m:b:a:s:So:U:w:e:E: flag; do
|
||||
case "$flag" in
|
||||
h) print_usage 1>&2
|
||||
exit 2
|
||||
@@ -546,7 +550,7 @@ function parse_command_line
|
||||
;;
|
||||
m) MDTAG="$OPTARG"
|
||||
;;
|
||||
b) # parse: -p tool
|
||||
b) # parse: -b tool
|
||||
if [[ $OPTARG == . ]]; then
|
||||
# unset before tool
|
||||
BEFORE_TOOL=
|
||||
@@ -555,19 +559,6 @@ function parse_command_line
|
||||
BEFORE_TOOL="$OPTARG"
|
||||
fi
|
||||
;;
|
||||
p) # parse -p tool
|
||||
if [[ $OPTARG == . ]]; then
|
||||
# unset pandoc wrapper tool
|
||||
PANDOC_WRAPPER=
|
||||
else
|
||||
# change pandoc wrapper tool
|
||||
PANDOC_WRAPPER="$OPTARG"
|
||||
fi
|
||||
B_OPTION+=("-p")
|
||||
B_OPTION+=("$PANDOC_WRAPPER")
|
||||
A_OPTION+=("-p")
|
||||
A_OPTION+=("$PANDOC_WRAPPER")
|
||||
;;
|
||||
a) # parse: -a tool
|
||||
if [[ $OPTARG == . ]]; then
|
||||
# unset after tool
|
||||
@@ -678,6 +669,7 @@ function parse_command_line
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# debug_parameters - if verbose enough, print parameters
|
||||
#
|
||||
# usage:
|
||||
@@ -716,7 +708,6 @@ function debug_parameters
|
||||
echo "$0: debug[$DEBUG_LEVEL]: $DBG_PREFIX: PERL_TOOL=$PERL_TOOL" 1>&2
|
||||
echo "$0: debug[$DEBUG_LEVEL]: $DBG_PREFIX: TOPDIR=$TOPDIR" 1>&2
|
||||
echo "$0: debug[$DEBUG_LEVEL]: $DBG_PREFIX: DOCROOT_SLASH=$DOCROOT_SLASH" 1>&2
|
||||
echo "$0: debug[$DEBUG_LEVEL]: $DBG_PREFIX: PANDOC_WRAPPER=$PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: debug[$DEBUG_LEVEL]: $DBG_PREFIX: REPO_TOP_URL=$REPO_TOP_URL" 1>&2
|
||||
echo "$0: debug[$DEBUG_LEVEL]: $DBG_PREFIX: REPO_URL=$REPO_URL" 1>&2
|
||||
echo "$0: debug[$DEBUG_LEVEL]: $DBG_PREFIX: SITE_URL=$SITE_URL" 1>&2
|
||||
@@ -766,10 +757,12 @@ function debug_parameters
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
#################################
|
||||
# md2html.cfg related functions #
|
||||
#################################
|
||||
|
||||
|
||||
# match_md2html - first file_glob match for md2html.cfg file
|
||||
#
|
||||
# usage:
|
||||
@@ -897,10 +890,12 @@ function match_md2html
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
################################
|
||||
# HTML phase related functions #
|
||||
################################
|
||||
|
||||
|
||||
# append_html_phase - append a sed modified HTML phase file to a growing temporary HTML file
|
||||
#
|
||||
# usage:
|
||||
@@ -1033,24 +1028,30 @@ function append_html_phase
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
###################################
|
||||
# required initial variable setup #
|
||||
###################################
|
||||
|
||||
|
||||
global_variable_setup
|
||||
|
||||
|
||||
##################
|
||||
# getopt phase 0 #
|
||||
##################
|
||||
|
||||
|
||||
# set getopt phase to 0
|
||||
#
|
||||
GETOPT_PHASE=0
|
||||
|
||||
|
||||
# process command line options
|
||||
#
|
||||
parse_command_line "$@"
|
||||
|
||||
|
||||
# parse the command line arguments
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -1088,6 +1089,7 @@ if [[ $MATCH_MD == - ]]; then
|
||||
exit 3
|
||||
fi
|
||||
|
||||
|
||||
# determine working directory
|
||||
#
|
||||
# We will use the dirname of match.md as our working directory. This is path from
|
||||
@@ -1099,6 +1101,7 @@ fi
|
||||
WORKING_DIR=$(dirname "$MATCH_MD")
|
||||
export WORKING_DIR
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -1119,6 +1122,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -1142,14 +1146,6 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
# verify that we have an inc subdirectory
|
||||
#
|
||||
export INC_PATH="$TOPDIR/inc"
|
||||
if [[ ! -d $INC_PATH ]]; then
|
||||
echo "$0: ERROR: inc is not a directory under topdir: $INC_PATH" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export INC_DIR="inc"
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
@@ -1161,6 +1157,33 @@ fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
|
||||
# verify that the bin/pandoc-wrapper.sh tool is executable
|
||||
#
|
||||
export PANDOC_WRAPPER="$BIN_DIR/pandoc-wrapper.sh"
|
||||
if [[ ! -e $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh does not exist: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not a regular file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not an executable file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have an inc subdirectory
|
||||
#
|
||||
export INC_PATH="$TOPDIR/inc"
|
||||
if [[ ! -d $INC_PATH ]]; then
|
||||
echo "$0: ERROR: inc is not a directory under topdir: $INC_PATH" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export INC_DIR="inc"
|
||||
|
||||
|
||||
# verify that we have a readable .top file
|
||||
#
|
||||
export TOP="$TOPDIR/.top"
|
||||
@@ -1177,6 +1200,7 @@ if [[ ! -r $TOP ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# verify we have a readable md2html.cfg file
|
||||
#
|
||||
if [[ -z $MD2HTML_CFG ]]; then
|
||||
@@ -1195,6 +1219,7 @@ if [[ ! -r $MD2HTML_CFG ]]; then
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# new parameter debugging
|
||||
#
|
||||
debug_parameters 5 "after parse in getopt phase: $GETOPT_PHASE"
|
||||
@@ -1203,10 +1228,12 @@ if [[ $V_FLAG -ge 5 ]]; then
|
||||
echo "$0: debug[5]: end getopt phase ${GETOPT_PHASE} debug level: $V_FLAG" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
##################
|
||||
# getopt phase 1 #
|
||||
##################
|
||||
|
||||
|
||||
# set getopt phase to 1
|
||||
#
|
||||
GETOPT_PHASE=1
|
||||
@@ -1215,6 +1242,7 @@ if [[ $V_FLAG -ge 5 ]]; then
|
||||
echo "$0: debug[5]: begin getopt phase ${GETOPT_PHASE} debug level: $V_FLAG" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# run output tools and parse output as more options
|
||||
#
|
||||
# report output tools and output tool options
|
||||
@@ -1224,6 +1252,7 @@ if [[ $V_FLAG -ge 5 ]]; then
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# verify output tools are executable
|
||||
#
|
||||
for n in "${!OUTPUT_TOOL[@]}"; do
|
||||
@@ -1242,6 +1271,7 @@ for n in "${!OUTPUT_TOOL[@]}"; do
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# pre-clear our output tool options array
|
||||
#
|
||||
# NOTE: The OUTPUT_TOOL_OPTIONS array contains the options that an "output tool" produces.
|
||||
@@ -1250,6 +1280,7 @@ done
|
||||
unset OUTPUT_TOOL_OPTIONS
|
||||
declare -ag OUTPUT_TOOL_OPTIONS
|
||||
|
||||
|
||||
# execute each output tool and parse the output tool's options and arguments
|
||||
#
|
||||
for n in "${!OUTPUT_TOOL[@]}"; do
|
||||
@@ -1272,6 +1303,7 @@ for n in "${!OUTPUT_TOOL[@]}"; do
|
||||
done
|
||||
done
|
||||
|
||||
|
||||
# process command line arguments from all output tools
|
||||
#
|
||||
if [[ ${#OUTPUT_TOOL_OPTIONS[@]} -gt 0 ]]; then
|
||||
@@ -1286,6 +1318,7 @@ fi
|
||||
#
|
||||
debug_parameters 5 "after parse in getopt phase: $GETOPT_PHASE"
|
||||
|
||||
|
||||
# clear output tools and output tool options
|
||||
#
|
||||
unset OUTPUT_TOOL
|
||||
@@ -1297,10 +1330,12 @@ if [[ $V_FLAG -ge 5 ]]; then
|
||||
echo "$0: debug[5]: end getopt phase ${GETOPT_PHASE} debug level: $V_FLAG" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
##################
|
||||
# getopt phase 2 #
|
||||
##################
|
||||
|
||||
|
||||
# set getopt phase to 2
|
||||
#
|
||||
GETOPT_PHASE=2
|
||||
@@ -1309,11 +1344,13 @@ if [[ $V_FLAG -ge 5 ]]; then
|
||||
echo "$0: debug[5]: begin getopt phase ${GETOPT_PHASE} debug level: $V_FLAG" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# setup an empty MATCH_OPTIONS array for match_md2html to append options
|
||||
#
|
||||
unset MATCH_OPTIONS
|
||||
declare -ag MATCH_OPTIONS
|
||||
|
||||
|
||||
# find the first match md2html.cfg for the 'match.md' argument
|
||||
#
|
||||
match_md2html "$MD2HTML_CFG" "$MATCH_MD"
|
||||
@@ -1323,6 +1360,7 @@ status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: Warning: $MATCH_MD does not match any lines in: $MD2HTML_CFG, match_md2html return code: $status" 1>&2
|
||||
|
||||
|
||||
# case: MATCH_MD matched and command line options were appended to MATCH_OPTIONS
|
||||
#
|
||||
elif [[ ${#MATCH_OPTIONS[@]} -gt 0 ]]; then
|
||||
@@ -1341,6 +1379,7 @@ elif [[ ${#MATCH_OPTIONS[@]} -gt 0 ]]; then
|
||||
#
|
||||
parse_command_line "${MATCH_OPTIONS[@]}"
|
||||
|
||||
|
||||
# case: MATCH_MD matched and no command line options found
|
||||
#
|
||||
elif [[ $V_FLAG -ge 5 ]]; then
|
||||
@@ -1353,10 +1392,12 @@ if [[ $V_FLAG -ge 5 ]]; then
|
||||
echo "$0: debug[5]: end getopt phase ${GETOPT_PHASE} debug level: $V_FLAG" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
##################
|
||||
# getopt phase 3 #
|
||||
##################
|
||||
|
||||
|
||||
# set getopt phase to 3
|
||||
#
|
||||
GETOPT_PHASE=3
|
||||
@@ -1365,6 +1406,7 @@ if [[ $V_FLAG -ge 5 ]]; then
|
||||
echo "$0: debug[5]: begin getopt phase ${GETOPT_PHASE} debug level: $V_FLAG" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# run output tools and parse output as more options
|
||||
#
|
||||
# report output tools and output tool options
|
||||
@@ -1374,6 +1416,7 @@ if [[ $V_FLAG -ge 5 ]]; then
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# verify output tools are executable
|
||||
#
|
||||
for n in "${!OUTPUT_TOOL[@]}"; do
|
||||
@@ -1392,6 +1435,7 @@ for n in "${!OUTPUT_TOOL[@]}"; do
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# pre-clear our output tool options array
|
||||
#
|
||||
# NOTE: The OUTPUT_TOOL_OPTIONS array contains the options that an "output tool" produces.
|
||||
@@ -1400,6 +1444,7 @@ done
|
||||
unset OUTPUT_TOOL_OPTIONS
|
||||
declare -ag OUTPUT_TOOL_OPTIONS
|
||||
|
||||
|
||||
# execute each output tool and parse the output tool's options and arguments
|
||||
#
|
||||
for n in "${!OUTPUT_TOOL[@]}"; do
|
||||
@@ -1422,6 +1467,7 @@ for n in "${!OUTPUT_TOOL[@]}"; do
|
||||
done
|
||||
done
|
||||
|
||||
|
||||
# process command line arguments from all output tools
|
||||
#
|
||||
if [[ ${#OUTPUT_TOOL_OPTIONS[@]} -gt 0 ]]; then
|
||||
@@ -1436,6 +1482,7 @@ fi
|
||||
#
|
||||
debug_parameters 5 "after parse in getopt phase: $GETOPT_PHASE"
|
||||
|
||||
|
||||
# clear output tools and output tool options
|
||||
#
|
||||
unset OUTPUT_TOOL
|
||||
@@ -1447,10 +1494,12 @@ if [[ $V_FLAG -ge 5 ]]; then
|
||||
echo "$0: debug[5]: end getopt phase ${GETOPT_PHASE} debug level: $V_FLAG" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
############################################
|
||||
# debugging after getopt phase is complete #
|
||||
############################################
|
||||
|
||||
|
||||
# set getopt phase to 4
|
||||
#
|
||||
GETOPT_PHASE=4
|
||||
@@ -1464,7 +1513,6 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: V_FLAG=$V_FLAG" 1>&2
|
||||
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: GIT_TOOL=$GIT_TOOL" 1>&2
|
||||
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: DOCROOT_SLASH=$DOCROOT_SLASH" 1>&2
|
||||
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: PANDOC_WRAPPER=$PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: REPO_TOP_URL=$REPO_TOP_URL" 1>&2
|
||||
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: REPO_URL=$REPO_URL" 1>&2
|
||||
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: SITE_URL=$SITE_URL" 1>&2
|
||||
@@ -1473,12 +1521,16 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: REPO_NAME=$REPO_NAME" 1>&2
|
||||
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: INC_PATH=$INC_PATH" 1>&2
|
||||
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: INC_DIR=$INC_DIR" 1>&2
|
||||
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: BIN_PATH=$BIN_PATH" 1>&2
|
||||
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: BIN_DIR=$BIN_DIR" 1>&2
|
||||
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: PANDOC_WRAPPER=$PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: TOP=$TOP" 1>&2
|
||||
fi
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: finished all getopt parsing" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# validate HTML phase names
|
||||
#
|
||||
for n in "${PHASE_NAME[@]}"; do
|
||||
@@ -1506,6 +1558,7 @@ for n in "${PHASE_NAME[@]}"; do
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# validate before tool
|
||||
#
|
||||
if [[ -n $BEFORE_TOOL ]]; then
|
||||
@@ -1528,27 +1581,6 @@ if [[ -n $BEFORE_TOOL ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# validate pandoc wrapper tool
|
||||
#
|
||||
if [[ -n $PANDOC_WRAPPER ]]; then
|
||||
if [[ $V_FLAG -ge 5 ]]; then
|
||||
if [[ -n $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: debug[5]: -p pandoc wrapper tool: $PANDOC_WRAPPER" 1>&2
|
||||
fi
|
||||
fi
|
||||
if [[ ! -e "$PANDOC_WRAPPER" ]]; then
|
||||
echo "$0: ERROR: -p pandoc wrapper tool not found: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f "$PANDOC_WRAPPER" ]]; then
|
||||
echo "$0: ERROR: -p pandoc wrapper tool not a file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x "$PANDOC_WRAPPER" ]]; then
|
||||
echo "$0: ERROR: -p pandoc wrapper tool not an executable file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
fi
|
||||
|
||||
# validate after tool
|
||||
#
|
||||
@@ -1572,6 +1604,7 @@ if [[ -n $AFTER_TOOL ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# report TOKEN sed patterns
|
||||
#
|
||||
if [[ $V_FLAG -ge 7 ]]; then
|
||||
@@ -1589,10 +1622,12 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
##########################
|
||||
# HTML pre-0 phase setup #
|
||||
##########################
|
||||
|
||||
|
||||
# create a temporary sed script
|
||||
#
|
||||
export TMP_SED_SCRIPT=".tmp.$NAME.SED_SCRIPT.$$.tmp"
|
||||
@@ -1634,6 +1669,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: the temporary sed script that would have been written ends above: $TMP_SED_SCRIPT" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary HTML phase file
|
||||
#
|
||||
# NOTE: This file, when we are finished building it, will be come the final index.html file.
|
||||
@@ -1661,6 +1697,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary HTML file is not formed: $TMP_PHASE" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary index HTML file
|
||||
#
|
||||
# NOTE: This file, when we are finished building it, will be come the final index.html file.
|
||||
@@ -1688,6 +1725,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary index HTML file is not formed: $TMP_INDEX_HTML" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# input.md is -, we will need to capture standard input into a new temporary file
|
||||
#
|
||||
export ORIG_INPUT_MD="$MATCH_MD"
|
||||
@@ -1733,6 +1771,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary stdin file is not formed: $TMP_INPUT_MD" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# strip commented language after markdown code block
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -1784,6 +1823,7 @@ fi
|
||||
# HTML phase 0: inc/top.__name__.html #
|
||||
#######################################
|
||||
|
||||
|
||||
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
|
||||
#
|
||||
export CUR_PHASE_NUM=0
|
||||
@@ -1799,10 +1839,12 @@ if [[ $status -ne 0 ]]; then
|
||||
exit "$status"
|
||||
fi
|
||||
|
||||
|
||||
########################################
|
||||
# HTML phase 1: inc/head.__name__.html #
|
||||
########################################
|
||||
|
||||
|
||||
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
|
||||
#
|
||||
CUR_PHASE_NUM=1
|
||||
@@ -1818,6 +1860,7 @@ if [[ $status -ne 0 ]]; then
|
||||
exit "$status"
|
||||
fi
|
||||
|
||||
|
||||
# Special output to indicate which tool was used
|
||||
#
|
||||
if [[ -z $NOOP && ${HTML_PHASE_NAME[$CUR_PHASE_NAME]} != . ]]; then
|
||||
@@ -1849,10 +1892,12 @@ fi
|
||||
} >> "$TMP_INDEX_HTML"
|
||||
fi
|
||||
|
||||
|
||||
########################################
|
||||
# HTML phase 2: inc/body.__name__.html #
|
||||
########################################
|
||||
|
||||
|
||||
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
|
||||
#
|
||||
CUR_PHASE_NUM=2
|
||||
@@ -1868,10 +1913,12 @@ if [[ $status -ne 0 ]]; then
|
||||
exit "$status"
|
||||
fi
|
||||
|
||||
|
||||
########################################
|
||||
# HTML phase 3: inc/topbar.__name__.html #
|
||||
########################################
|
||||
|
||||
|
||||
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
|
||||
#
|
||||
CUR_PHASE_NUM=3
|
||||
@@ -1887,10 +1934,12 @@ if [[ $status -ne 0 ]]; then
|
||||
exit "$status"
|
||||
fi
|
||||
|
||||
|
||||
##########################################
|
||||
# HTML phase 4: inc/header.__name__.html #
|
||||
##########################################
|
||||
|
||||
|
||||
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
|
||||
#
|
||||
CUR_PHASE_NUM=4
|
||||
@@ -1906,10 +1955,12 @@ if [[ $status -ne 0 ]]; then
|
||||
exit "$status"
|
||||
fi
|
||||
|
||||
|
||||
##########################################
|
||||
# HTML phase 5: inc/navbar.__name__.html #
|
||||
##########################################
|
||||
|
||||
|
||||
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
|
||||
#
|
||||
CUR_PHASE_NUM=5
|
||||
@@ -1925,10 +1976,12 @@ if [[ $status -ne 0 ]]; then
|
||||
exit "$status"
|
||||
fi
|
||||
|
||||
|
||||
###################################################
|
||||
# HTML phase 6: inc/before-content.__name__.html #
|
||||
###################################################
|
||||
|
||||
|
||||
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
|
||||
#
|
||||
CUR_PHASE_NUM=6
|
||||
@@ -1944,10 +1997,12 @@ if [[ $status -ne 0 ]]; then
|
||||
exit "$status"
|
||||
fi
|
||||
|
||||
|
||||
##############################
|
||||
# HTML phase 20: before tool #
|
||||
##############################
|
||||
|
||||
|
||||
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
|
||||
#
|
||||
CUR_PHASE_NUM=20
|
||||
@@ -2004,10 +2059,12 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: successfully completed HTML phase $CUR_PHASE_NUM ($CUR_PHASE_NAME)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
######################################
|
||||
# HTML phase 21: pandoc wrapper tool #
|
||||
######################################
|
||||
|
||||
|
||||
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
|
||||
#
|
||||
CUR_PHASE_NUM=21
|
||||
@@ -2019,100 +2076,98 @@ if [[ $V_FLAG -ge 5 ]]; then
|
||||
done
|
||||
fi
|
||||
#
|
||||
if [[ -n $PANDOC_WRAPPER ]]; then
|
||||
if [[ -z $NOOP ]]; then
|
||||
if [[ -z $NOOP ]]; then
|
||||
|
||||
# write START of section comment
|
||||
#
|
||||
{
|
||||
echo "<!-- START: this line starts content for HTML phase $CUR_PHASE_NUM" \
|
||||
"by: $PANDOC_WRAPPER via bin/$NAME -->"
|
||||
echo
|
||||
} >> "$TMP_INDEX_HTML"
|
||||
# write START of section comment
|
||||
#
|
||||
{
|
||||
echo "<!-- START: this line starts content for HTML phase $CUR_PHASE_NUM" \
|
||||
"by: $PANDOC_WRAPPER via bin/$NAME -->"
|
||||
echo
|
||||
} >> "$TMP_INDEX_HTML"
|
||||
|
||||
# append pandoc wrapper tool output
|
||||
#
|
||||
if [[ $V_FLAG -ge 5 ]]; then
|
||||
echo "$0: debug[5]: about to execute:" \
|
||||
"$PANDOC_WRAPPER ${P_OPTION[*]} -- $TMP_STRIPPED_MD - >> $TMP_INDEX_HTML" 1>&2
|
||||
fi
|
||||
"$PANDOC_WRAPPER" "${P_OPTION[@]}" -- "$TMP_STRIPPED_MD" - >> "$TMP_INDEX_HTML"
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: pandoc wrapper tool:" \
|
||||
"$PANDOC_WRAPPER ${P_OPTION[*]} -- $TMP_STRIPPED_MD - failed," \
|
||||
"error code: $status" 1>&2
|
||||
exit 100
|
||||
fi
|
||||
|
||||
# fix any pandoc footnote bogons
|
||||
#
|
||||
# The pandoc(1) tool will generate the following BOGUS HTML 5 code
|
||||
# when any markdown footnotes are used:
|
||||
#
|
||||
# <!-- AFTER: last line of markdown file: PATH/FILE/NAME -->
|
||||
# <section id="footnotes" class="footnotes footnotes-end-of-document" role="doc-endnotes">
|
||||
# <hr />
|
||||
#
|
||||
# The section element lacks any HTML h1..h6 heading element inside it,
|
||||
# and "<hr />" has no effect in standard HTML 5 and interacts badly with
|
||||
# unquoted attribute values.
|
||||
#
|
||||
# We replace such HTML 5 with HTML 5 code as follows:
|
||||
#
|
||||
# <!-- AFTER: last line of markdown file: PATH/FILE/NAME -->
|
||||
# <hr style="width:10%;text-align:left;margin-left:0">
|
||||
# <section id="footnotes" class="footnotes footnotes-end-of-document" role="doc-endnotes">
|
||||
# <h5>Footnotes</h5>
|
||||
#
|
||||
# It is easier to compose a perl script inline than to use an external file
|
||||
# because we then have to test for that perl script to be a non-empty readable file,
|
||||
# and perhaps allow some arg to specify an alternate location for the perl script/
|
||||
# So instead we just build the perl script inline.
|
||||
#
|
||||
PERL_LINE='s|(<!-- AFTER: last line of markdown file: \S+ -->)\n'
|
||||
PERL_LINE="$PERL_LINE"'(<section id="footnotes" class="footnotes footnotes-end-of-document" role="doc-endnotes">)\n'
|
||||
PERL_LINE="$PERL_LINE"'<hr />|'
|
||||
PERL_LINE="$PERL_LINE\$1"'\n'
|
||||
PERL_LINE="$PERL_LINE"'<hr style="width:10%;text-align:left;margin-left:0">\n'
|
||||
PERL_LINE="$PERL_LINE\$2"'\n'
|
||||
PERL_LINE="$PERL_LINE"'<h5>Footnotes</h5>|gms'
|
||||
if [[ $V_FLAG -ge 5 ]]; then
|
||||
echo "$0: debug[5]: about to execute:" \
|
||||
"$PERL_TOOL -0 -p -i -e $PERL_LINE -- $TMP_INDEX_HTML" 1>&2
|
||||
fi
|
||||
|
||||
"$PERL_TOOL" -0 -p -i -e "$PERL_LINE" -- "$TMP_INDEX_HTML"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: pandoc wrapper tool:" \
|
||||
"$PERL_TOOL -0 -p -i -e $PERL_LINE -- $TMP_INDEX_HTML - failed," \
|
||||
"error code: $status" 1>&2
|
||||
exit 101
|
||||
fi
|
||||
|
||||
# write START of section comment
|
||||
#
|
||||
{
|
||||
echo
|
||||
echo "<!-- END: this line ends content for HTML phase $CUR_PHASE_NUM" \
|
||||
"by: $PANDOC_WRAPPER via bin/$NAME -->"
|
||||
} >> "$TMP_INDEX_HTML"
|
||||
|
||||
elif [[ $V_FLAG -ge 5 ]]; then
|
||||
echo "$0: debug[5]: because of -n, disabled use of pandoc wrapper tool: $PANDOC_WRAPPER" 1>&2
|
||||
# append pandoc wrapper tool output
|
||||
#
|
||||
if [[ $V_FLAG -ge 5 ]]; then
|
||||
echo "$0: debug[5]: about to execute:" \
|
||||
"$PANDOC_WRAPPER ${P_OPTION[*]} -- $TMP_STRIPPED_MD - >> $TMP_INDEX_HTML" 1>&2
|
||||
fi
|
||||
"$PANDOC_WRAPPER" "${P_OPTION[@]}" -- "$TMP_STRIPPED_MD" - >> "$TMP_INDEX_HTML"
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: pandoc wrapper tool:" \
|
||||
"$PANDOC_WRAPPER ${P_OPTION[*]} -- $TMP_STRIPPED_MD - failed," \
|
||||
"error code: $status" 1>&2
|
||||
exit 100
|
||||
fi
|
||||
|
||||
# fix any pandoc footnote bogons
|
||||
#
|
||||
# The pandoc(1) tool will generate the following BOGUS HTML 5 code
|
||||
# when any markdown footnotes are used:
|
||||
#
|
||||
# <!-- AFTER: last line of markdown file: PATH/FILE/NAME -->
|
||||
# <section id="footnotes" class="footnotes footnotes-end-of-document" role="doc-endnotes">
|
||||
# <hr />
|
||||
#
|
||||
# The section element lacks any HTML h1..h6 heading element inside it,
|
||||
# and "<hr />" has no effect in standard HTML 5 and interacts badly with
|
||||
# unquoted attribute values.
|
||||
#
|
||||
# We replace such HTML 5 with HTML 5 code as follows:
|
||||
#
|
||||
# <!-- AFTER: last line of markdown file: PATH/FILE/NAME -->
|
||||
# <hr style="width:10%;text-align:left;margin-left:0">
|
||||
# <section id="footnotes" class="footnotes footnotes-end-of-document" role="doc-endnotes">
|
||||
# <h5>Footnotes</h5>
|
||||
#
|
||||
# It is easier to compose a perl script inline than to use an external file
|
||||
# because we then have to test for that perl script to be a non-empty readable file,
|
||||
# and perhaps allow some arg to specify an alternate location for the perl script/
|
||||
# So instead we just build the perl script inline.
|
||||
#
|
||||
PERL_LINE='s|(<!-- AFTER: last line of markdown file: \S+ -->)\n'
|
||||
PERL_LINE="$PERL_LINE"'(<section id="footnotes" class="footnotes footnotes-end-of-document" role="doc-endnotes">)\n'
|
||||
PERL_LINE="$PERL_LINE"'<hr />|'
|
||||
PERL_LINE="$PERL_LINE\$1"'\n'
|
||||
PERL_LINE="$PERL_LINE"'<hr style="width:10%;text-align:left;margin-left:0">\n'
|
||||
PERL_LINE="$PERL_LINE\$2"'\n'
|
||||
PERL_LINE="$PERL_LINE"'<h5>Footnotes</h5>|gms'
|
||||
if [[ $V_FLAG -ge 5 ]]; then
|
||||
echo "$0: debug[5]: about to execute:" \
|
||||
"$PERL_TOOL -0 -p -i -e $PERL_LINE -- $TMP_INDEX_HTML" 1>&2
|
||||
fi
|
||||
|
||||
"$PERL_TOOL" -0 -p -i -e "$PERL_LINE" -- "$TMP_INDEX_HTML"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: pandoc wrapper tool:" \
|
||||
"$PERL_TOOL -0 -p -i -e $PERL_LINE -- $TMP_INDEX_HTML - failed," \
|
||||
"error code: $status" 1>&2
|
||||
exit 101
|
||||
fi
|
||||
|
||||
# write START of section comment
|
||||
#
|
||||
{
|
||||
echo
|
||||
echo "<!-- END: this line ends content for HTML phase $CUR_PHASE_NUM" \
|
||||
"by: $PANDOC_WRAPPER via bin/$NAME -->"
|
||||
} >> "$TMP_INDEX_HTML"
|
||||
|
||||
elif [[ $V_FLAG -ge 5 ]]; then
|
||||
echo "$0: debug[5]: because of -p ., use of pandoc wrapper tool was disabled" 1>&2
|
||||
echo "$0: debug[5]: because of -n, disabled use of pandoc wrapper tool: $PANDOC_WRAPPER" 1>&2
|
||||
fi
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: successfully completed HTML phase $CUR_PHASE_NUM ($CUR_PHASE_NAME)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
#############################
|
||||
# HTML phase 22: after tool #
|
||||
#############################
|
||||
|
||||
|
||||
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
|
||||
#
|
||||
CUR_PHASE_NUM=22
|
||||
@@ -2169,10 +2224,12 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: successfully completed HTML phase $CUR_PHASE_NUM" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
##################################################
|
||||
# HTML phase 30: inc/after-content.__name__.html #
|
||||
##################################################
|
||||
|
||||
|
||||
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
|
||||
#
|
||||
CUR_PHASE_NUM=30
|
||||
@@ -2188,10 +2245,12 @@ if [[ $status -ne 0 ]]; then
|
||||
exit "$status"
|
||||
fi
|
||||
|
||||
|
||||
###########################################
|
||||
# HTML phase 31: inc/footer.__name__.html #
|
||||
###########################################
|
||||
|
||||
|
||||
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
|
||||
#
|
||||
CUR_PHASE_NUM=31
|
||||
@@ -2207,10 +2266,12 @@ if [[ $status -ne 0 ]]; then
|
||||
exit "$status"
|
||||
fi
|
||||
|
||||
|
||||
###########################################
|
||||
# HTML phase 32: inc/bottom.__name__.html #
|
||||
###########################################
|
||||
|
||||
|
||||
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
|
||||
#
|
||||
CUR_PHASE_NUM=32
|
||||
@@ -2226,10 +2287,12 @@ if [[ $status -ne 0 ]]; then
|
||||
exit "$status"
|
||||
fi
|
||||
|
||||
|
||||
################################
|
||||
# finalize the index.html file #
|
||||
################################
|
||||
|
||||
|
||||
# sanity check - temporary index HTML file must be a readable file
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -2252,6 +2315,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, disabled readable file check of: $TMP_PHASE_FILE 2>/dev/null" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# move temporary index HTML in place
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -2312,6 +2376,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, disabled: mv -f -- $TMP_INDEX_HTML $OUTPUT_HTML" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# file cleanup
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -2321,6 +2386,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
"$TMP_SED_SCRIPT $TMP_PHASE $TMP_INDEX_HTML $TMP_INPUT_MD $TMP_STRIPPED_MD" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
if [[ -n $NOOP ]]; then
|
||||
|
||||
+7
-11
@@ -29,6 +29,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -139,6 +140,7 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:nN flag; do
|
||||
@@ -174,7 +176,7 @@ while getopts :hv:Vd:nN flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# remove the options
|
||||
#
|
||||
shift $(( OPTIND - 1 ));
|
||||
@@ -193,6 +195,7 @@ if [[ $# -ne 1 ]]; then
|
||||
fi
|
||||
export ENTRY_PATH="$1"
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -213,6 +216,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -236,6 +240,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify we have a non-empty readable .top file
|
||||
#
|
||||
export TOP_FILE=".top"
|
||||
@@ -256,14 +261,6 @@ if [[ ! -s $TOP_FILE ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
if [[ ! -d $BIN_PATH ]]; then
|
||||
echo "$0: ERROR: bin is not a directory under topdir: $BIN_PATH" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# verify that ENTRY_PATH is a entry directory
|
||||
#
|
||||
@@ -350,8 +347,6 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: REPO_NAME=$REPO_NAME" 1>&2
|
||||
echo "$0: debug[3]: CD_FAILED=$CD_FAILED" 1>&2
|
||||
echo "$0: debug[3]: TOP_FILE=$TOP_FILE" 1>&2
|
||||
echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2
|
||||
echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2
|
||||
echo "$0: debug[3]: YEAR_DIR=$YEAR_DIR" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_DIR=$ENTRY_DIR" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_ID=$ENTRY_ID" 1>&2
|
||||
@@ -360,6 +355,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: MAKE_FILE=$MAKE_FILE" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# -N stops early before any processing is performed
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
|
||||
+4
-1
@@ -28,6 +28,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -233,6 +234,7 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:nN flag; do
|
||||
@@ -268,7 +270,7 @@ while getopts :hv:Vd:nN flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# remove the options
|
||||
#
|
||||
shift $(( OPTIND - 1 ));
|
||||
@@ -400,6 +402,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: MAKE_FILE=$MAKE_FILE" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# -N stops early before any processing is performed
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
|
||||
+92
-64
@@ -44,6 +44,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -87,6 +88,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -99,9 +101,10 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.7.3 2024-08-05"
|
||||
export VERSION="1.8 2024-08-17"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -118,17 +121,17 @@ if [[ $status -eq 0 ]]; then
|
||||
fi
|
||||
export TOPDIR
|
||||
export DOCROOT_SLASH="../../"
|
||||
export PANDOC_WRAPPER="bin/pandoc-wrapper.sh"
|
||||
export REPO_TOP_URL="https://github.com/ioccc-src/temp-test-ioccc"
|
||||
# GitHub puts individual files under the "blob/master" sub-directory.
|
||||
export REPO_URL="$REPO_TOP_URL/blob/master"
|
||||
export SITE_URL="https://ioccc-src.github.io/temp-test-ioccc"
|
||||
export URL="#"
|
||||
|
||||
|
||||
# set usage message
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
[-p tool] [-U url] [-w site_url] [-e string ..] [-E exitcode]
|
||||
[-U url] [-w site_url] [-e string ..] [-E exitcode]
|
||||
YYYY/dir
|
||||
|
||||
-h print help message and exit
|
||||
@@ -142,8 +145,6 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
-n go thru the actions, but do not update any files (def: do the action)
|
||||
-N do not process file, just parse arguments and ignore the file (def: process the file)
|
||||
|
||||
-p tool run 'pandoc wrapper tool' (not pandoc path) during HTML phase number 21 (def: use $PANDOC_WRAPPER)
|
||||
|
||||
-U url URL of HTML file being formed (def: $URL)
|
||||
-w site_url Base URL of the website (def: $SITE_URL)
|
||||
|
||||
@@ -166,21 +167,17 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# setup
|
||||
#
|
||||
export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
|
||||
|
||||
# output_author_handles
|
||||
#
|
||||
# Write the author handle(s) for the YYYY/dir entry to standard output (stdout)
|
||||
#
|
||||
# XXX - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XXX
|
||||
# XXX - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - XXX
|
||||
# XXX - until we have the jnamval command, we must FAKE PARSE the .entry.json file - XXX
|
||||
# XXX - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - XXX
|
||||
# XXX - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XXX
|
||||
#
|
||||
# usage:
|
||||
# output_author_handles YYYY/dir/.entry.json
|
||||
#
|
||||
@@ -191,7 +188,6 @@ export DO_NOT_PROCESS=
|
||||
function output_author_handles
|
||||
{
|
||||
local ENTRY_JSON_PATH; # the .entry.json path
|
||||
local author_handle; # a found author handle
|
||||
|
||||
# parse args
|
||||
#
|
||||
@@ -215,25 +211,21 @@ function output_author_handles
|
||||
|
||||
# extract author handles from .entry.json
|
||||
#
|
||||
grep -F author_handle "$ENTRY_JSON_PATH" |
|
||||
awk 'NF == 5 { print $4; }' |
|
||||
tr -d '"' |
|
||||
while read -r author_handle; do
|
||||
echo "$author_handle"
|
||||
done
|
||||
"$JVAL_WRAPPER" -w -b "$ENTRY_JSON_PATH" '$..author_handle'
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: $JVAL_WRAPPER -w -b $ENTRY_JSON_PATH \$..author_handle failed," \
|
||||
"error: $status" 1>&2
|
||||
return 5
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# output_entry_ids
|
||||
#
|
||||
# Write the entry ids from an author/author_handle.json file to standard output (stdout)
|
||||
#
|
||||
# XXX - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XXX
|
||||
# XXX - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - XXX
|
||||
# XXX - until we have the jnamval command, we must FAKE PARSE the author/author_handle.json file - XXX
|
||||
# XXX - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - XXX
|
||||
# XXX - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XXX
|
||||
#
|
||||
# usage:
|
||||
# output_entry_ids author/author_handle.json
|
||||
#
|
||||
@@ -244,7 +236,6 @@ function output_author_handles
|
||||
function output_entry_ids
|
||||
{
|
||||
local AUTHOR_HANDLE_JSON_PATH; # the .entry.json path
|
||||
local entry_id; # a found entry id
|
||||
|
||||
# parse args
|
||||
#
|
||||
@@ -268,12 +259,13 @@ function output_entry_ids
|
||||
|
||||
# extract entry ids from the author/author_handle.json file
|
||||
#
|
||||
grep -F entry_id "$AUTHOR_HANDLE_JSON_PATH" |
|
||||
awk 'NF == 5 { print $4; }' |
|
||||
tr -d '"' |
|
||||
while read -r entry_id; do
|
||||
echo "$entry_id"
|
||||
done
|
||||
"$JVAL_WRAPPER" -w -b "$AUTHOR_HANDLE_JSON_PATH" '$..entry_id'
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: $JVAL_WRAPPER -w -b $AUTHOR_HANDLE_JSON_PATH \$..entry_id failed," \
|
||||
"error: $status" 1>&2
|
||||
return 5
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -281,12 +273,6 @@ function output_entry_ids
|
||||
#
|
||||
# Write the Full Name from an author/author_handle.json file to standard output (stdout)
|
||||
#
|
||||
# XXX - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XXX
|
||||
# XXX - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - XXX
|
||||
# XXX - until we have the jnamval command, we must FAKE PARSE the author/author_handle.json file - XXX
|
||||
# XXX - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - XXX
|
||||
# XXX - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XXX
|
||||
#
|
||||
# usage:
|
||||
# output_full_name author/author_handle.json
|
||||
#
|
||||
@@ -320,20 +306,21 @@ function output_full_name
|
||||
|
||||
# extract Full Name from the author/author_handle.json file
|
||||
#
|
||||
grep -F full_name "$AUTHOR_HANDLE_JSON_PATH" | sed -e 's/.*"full_name" : "//' -e 's/",.*//'
|
||||
"$JVAL_WRAPPER" -w -b "$AUTHOR_HANDLE_JSON_PATH" '$..full_name'
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: $JVAL_WRAPPER -w -b $AUTHOR_HANDLE_JSON_PATH \$..full_name failed," \
|
||||
"error: $status" 1>&2
|
||||
return 5
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# output_location_code
|
||||
#
|
||||
# Write the Location Code from an author/author_handle.json file to standard output (stdout)
|
||||
#
|
||||
# XXX - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XXX
|
||||
# XXX - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - XXX
|
||||
# XXX - until we have the jnamval command, we must FAKE PARSE the author/author_handle.json file - XXX
|
||||
# XXX - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - XXX
|
||||
# XXX - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XXX
|
||||
#
|
||||
# usage:
|
||||
# output_location_code author/author_handle.json
|
||||
#
|
||||
@@ -367,13 +354,20 @@ function output_location_code
|
||||
|
||||
# extract Location Code from the author/author_handle.json file
|
||||
#
|
||||
grep -F location_code "$AUTHOR_HANDLE_JSON_PATH" | sed -e 's/.*"location_code" : "*//' -e 's/"*,.*//'
|
||||
"$JVAL_WRAPPER" -w -b "$AUTHOR_HANDLE_JSON_PATH" '$..location_code'
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: $JVAL_WRAPPER -w -b $ENTRY_JSON_PATH \$..location_code failed," \
|
||||
"error: $status" 1>&2
|
||||
return 5
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNp:U:w:e:E: flag; do
|
||||
while getopts :hv:Vd:D:nNU:w:e:E: flag; do
|
||||
case "$flag" in
|
||||
h) echo "$USAGE" 1>&2
|
||||
exit 2
|
||||
@@ -400,8 +394,6 @@ while getopts :hv:Vd:D:nNp:U:w:e:E: flag; do
|
||||
;;
|
||||
N) DO_NOT_PROCESS="-N"
|
||||
;;
|
||||
p) PANDOC_WRAPPER="$OPTARG"
|
||||
;;
|
||||
U) URL="$OPTARG"
|
||||
;;
|
||||
w) SITE_URL="$OPTARG"
|
||||
@@ -427,7 +419,7 @@ while getopts :hv:Vd:D:nNp:U:w:e:E: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# parse the command line arguments
|
||||
#
|
||||
if [[ $V_FLAG -ge 1 ]]; then
|
||||
@@ -446,6 +438,7 @@ fi
|
||||
#
|
||||
export ENTRY_PATH="$1"
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -466,6 +459,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -489,6 +483,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have an author subdirectory
|
||||
#
|
||||
export AUTHOR_PATH="$TOPDIR/author"
|
||||
@@ -498,6 +493,7 @@ if [[ ! -d $AUTHOR_PATH ]]; then
|
||||
fi
|
||||
export AUTHOR_DIR="author"
|
||||
|
||||
|
||||
# verify that we have an inc subdirectory
|
||||
#
|
||||
export INC_PATH="$TOPDIR/inc"
|
||||
@@ -507,6 +503,7 @@ if [[ ! -d $INC_PATH ]]; then
|
||||
fi
|
||||
export INC_DIR="inc"
|
||||
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
@@ -516,6 +513,41 @@ if [[ ! -d $BIN_PATH ]]; then
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
|
||||
# verify that the bin/pandoc-wrapper.sh tool is executable
|
||||
#
|
||||
export PANDOC_WRAPPER="$BIN_DIR/pandoc-wrapper.sh"
|
||||
if [[ ! -e $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh does not exist: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not a regular file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not an executable file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that the bin/jval-wrapper.sh tool is executable
|
||||
#
|
||||
JVAL_WRAPPER="$BIN_DIR/jval-wrapper.sh"
|
||||
if [[ ! -e $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh does not exist: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh is not a regular file: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh is not an executable file: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that ENTRY_PATH is a entry directory
|
||||
#
|
||||
if [[ ! -d $ENTRY_PATH ]]; then
|
||||
@@ -589,20 +621,6 @@ if [[ ! -r $ENTRY_JSON ]]; then
|
||||
exit 7
|
||||
fi
|
||||
|
||||
# verify pandoc wrapper tool
|
||||
#
|
||||
if [[ ! -e $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: pandoc wrapper tool does not exist: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: pandoc wrapper tool is not a file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: pandoc wrapper tool is not an executable file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# find the location tool
|
||||
#
|
||||
@@ -619,6 +637,7 @@ if [[ ! -x $LOCATION_TOOL ]]; then
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# parameter debugging
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -628,7 +647,6 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: GIT_TOOL=$GIT_TOOL" 1>&2
|
||||
echo "$0: debug[3]: TOPDIR=$TOPDIR" 1>&2
|
||||
echo "$0: debug[3]: DOCROOT_SLASH=$DOCROOT_SLASH" 1>&2
|
||||
echo "$0: debug[3]: PANDOC_WRAPPER=$PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: REPO_TOP_URL=$REPO_TOP_URL" 1>&2
|
||||
echo "$0: debug[3]: REPO_URL=$REPO_URL" 1>&2
|
||||
echo "$0: debug[3]: SITE_URL=$SITE_URL" 1>&2
|
||||
@@ -644,6 +662,8 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: INC_DIR=$INC_DIR" 1>&2
|
||||
echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2
|
||||
echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2
|
||||
echo "$0: debug[3]: PANDOC_WRAPPER=$PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: JVAL_WRAPPER=$JVAL_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: YEAR_DIR=$YEAR_DIR" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_DIR=$ENTRY_DIR" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_ID=$ENTRY_ID" 1>&2
|
||||
@@ -655,6 +675,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: LOCATION_TOOL=$LOCATION_TOOL" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# Set AUTHOR_HANDLE_SET with author handles from .entry.json
|
||||
#
|
||||
AUTHOR_HANDLE_SET=$(output_author_handles "$ENTRY_JSON")
|
||||
@@ -670,6 +691,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: author handles found in $ENTRY_JSON end above" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify each author handle has a readable author/author_handle.json file
|
||||
#
|
||||
for author_handle in $AUTHOR_HANDLE_SET; do
|
||||
@@ -736,6 +758,7 @@ for author_handle in $AUTHOR_HANDLE_SET; do
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# If -N, time to exit
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -745,6 +768,7 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary markdown for pandoc to process
|
||||
#
|
||||
export TMP_FILE=".tmp.$NAME.FILE.$$.tmp"
|
||||
@@ -767,6 +791,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary markdown file is not used: $TMP_FILE" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# write author header to temporary markdown file
|
||||
#
|
||||
{
|
||||
@@ -788,6 +813,7 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# write each author's information to temporary markdown file
|
||||
#
|
||||
export NOT_FIRST_AUTHOR
|
||||
@@ -872,6 +898,7 @@ for author_handle in $AUTHOR_HANDLE_SET; do
|
||||
NOT_FIRST_AUTHOR="true"
|
||||
done
|
||||
|
||||
|
||||
# convert temporary markdown file into HTML
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -892,6 +919,7 @@ elif [[ $V_FLAG -ge 1 ]]; then
|
||||
echo "$0: debug[1]: -n disabled execution of: $PANDOC_WRAPPER $TMP_FILE -" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -87,6 +88,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -99,6 +101,7 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable '**' to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.4.3 2024-08-05"
|
||||
@@ -117,7 +120,6 @@ if [[ $status -eq 0 ]]; then
|
||||
TOPDIR=$("$GIT_TOOL" rev-parse --show-toplevel)
|
||||
fi
|
||||
export TOPDIR
|
||||
export PANDOC_WRAPPER="bin/pandoc-wrapper.sh"
|
||||
export DOCROOT_SLASH="../../"
|
||||
export REPO_TOP_URL="https://github.com/ioccc-src/temp-test-ioccc"
|
||||
# GitHub puts individual files under the "blob/master" sub-directory.
|
||||
@@ -125,10 +127,11 @@ export REPO_URL="$REPO_TOP_URL/blob/master"
|
||||
export SITE_URL="https://ioccc-src.github.io/temp-test-ioccc"
|
||||
export URL="#"
|
||||
|
||||
|
||||
# set usage message
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
[-p tool] [-U url] [-w site_url] [-e string ..] [-E exitcode]
|
||||
[-U url] [-w site_url] [-e string ..] [-E exitcode]
|
||||
YYYY/dir
|
||||
|
||||
-h print help message and exit
|
||||
@@ -142,8 +145,6 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
-n go thru the actions, but do not update any files (def: do the action)
|
||||
-N do not process file, just parse arguments and ignore the file (def: process the file)
|
||||
|
||||
-p tool run 'pandoc wrapper tool' (not pandoc path) during HTML phase number 21 (def: use $PANDOC_WRAPPER)
|
||||
|
||||
-U url URL of HTML file being formed (def: $URL)
|
||||
-w site_url Base URL of the website (def: $SITE_URL)
|
||||
|
||||
@@ -164,14 +165,16 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# setup
|
||||
#
|
||||
export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNp:U:w:e:E: flag; do
|
||||
while getopts :hv:Vd:D:nNU:w:e:E: flag; do
|
||||
case "$flag" in
|
||||
h) echo "$USAGE" 1>&2
|
||||
exit 2
|
||||
@@ -198,8 +201,6 @@ while getopts :hv:Vd:D:nNp:U:w:e:E: flag; do
|
||||
;;
|
||||
N) DO_NOT_PROCESS="-N"
|
||||
;;
|
||||
p) PANDOC_WRAPPER="$OPTARG"
|
||||
;;
|
||||
U) URL="$OPTARG"
|
||||
;;
|
||||
w) SITE_URL="$OPTARG"
|
||||
@@ -226,6 +227,7 @@ while getopts :hv:Vd:D:nNp:U:w:e:E: flag; do
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
# parse the command line arguments
|
||||
#
|
||||
if [[ $V_FLAG -ge 1 ]]; then
|
||||
@@ -244,6 +246,7 @@ fi
|
||||
#
|
||||
export ENTRY_PATH="$1"
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -264,6 +267,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -287,6 +291,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have an author subdirectory
|
||||
#
|
||||
export AUTHOR_PATH="$TOPDIR/author"
|
||||
@@ -296,6 +301,7 @@ if [[ ! -d $AUTHOR_PATH ]]; then
|
||||
fi
|
||||
export AUTHOR_DIR="author"
|
||||
|
||||
|
||||
# verify that we have an inc subdirectory
|
||||
#
|
||||
export INC_PATH="$TOPDIR/inc"
|
||||
@@ -305,6 +311,7 @@ if [[ ! -d $INC_PATH ]]; then
|
||||
fi
|
||||
export INC_DIR="inc"
|
||||
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
@@ -314,6 +321,41 @@ if [[ ! -d $BIN_PATH ]]; then
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
|
||||
# verify that the bin/pandoc-wrapper.sh tool is executable
|
||||
#
|
||||
export PANDOC_WRAPPER="$BIN_DIR/pandoc-wrapper.sh"
|
||||
if [[ ! -e $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh does not exist: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not a regular file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not an executable file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify we have our awk script
|
||||
#
|
||||
export MANIFEST_ENTRY_JSON_AWK="$BIN_DIR/manifest.entry.json.awk"
|
||||
if [[ ! -e $MANIFEST_ENTRY_JSON_AWK ]]; then
|
||||
echo "$0: ERROR: bin/manifest.entry.json.awk does not exist: $MANIFEST_ENTRY_JSON_AWK" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -f $MANIFEST_ENTRY_JSON_AWK ]]; then
|
||||
echo "$0: ERROR: bin/manifest.entry.json.awk is not a regular file: $MANIFEST_ENTRY_JSON_AWK" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -r $MANIFEST_ENTRY_JSON_AWK ]]; then
|
||||
echo "$0: ERROR: bin/manifest.entry.json.awk is not a readable file: $MANIFEST_ENTRY_JSON_AWK" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# verify that ENTRY_PATH is a entry directory
|
||||
#
|
||||
if [[ ! -d $ENTRY_PATH ]]; then
|
||||
@@ -387,6 +429,7 @@ if [[ ! -r $ENTRY_JSON ]]; then
|
||||
exit 7
|
||||
fi
|
||||
|
||||
|
||||
# verify pandoc wrapper tool
|
||||
#
|
||||
if [[ ! -e $PANDOC_WRAPPER ]]; then
|
||||
@@ -402,21 +445,6 @@ if [[ ! -x $PANDOC_WRAPPER ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify we have our awk script
|
||||
#
|
||||
export MANIFEST_ENTRY_JSON_AWK="$BIN_DIR/manifest.entry.json.awk"
|
||||
if [[ ! -e $MANIFEST_ENTRY_JSON_AWK ]]; then
|
||||
echo "$0: ERROR: bin/manifest.entry.json.awk does not exist: $MANIFEST_ENTRY_JSON_AWK" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -f $MANIFEST_ENTRY_JSON_AWK ]]; then
|
||||
echo "$0: ERROR: bin/manifest.entry.json.awk is not a regular file: $MANIFEST_ENTRY_JSON_AWK" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -r $MANIFEST_ENTRY_JSON_AWK ]]; then
|
||||
echo "$0: ERROR: bin/manifest.entry.json.awk is not a readable file: $MANIFEST_ENTRY_JSON_AWK" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# parameter debugging
|
||||
#
|
||||
@@ -426,7 +454,6 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: V_FLAG=$V_FLAG" 1>&2
|
||||
echo "$0: debug[3]: GIT_TOOL=$GIT_TOOL" 1>&2
|
||||
echo "$0: debug[3]: TOPDIR=$TOPDIR" 1>&2
|
||||
echo "$0: debug[3]: PANDOC_WRAPPER=$PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: DOCROOT_SLASH=$DOCROOT_SLASH" 1>&2
|
||||
echo "$0: debug[3]: REPO_TOP_URL=$REPO_TOP_URL" 1>&2
|
||||
echo "$0: debug[3]: REPO_URL=$REPO_URL" 1>&2
|
||||
@@ -443,6 +470,8 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: INC_DIR=$INC_DIR" 1>&2
|
||||
echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2
|
||||
echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2
|
||||
echo "$0: debug[3]: PANDOC_WRAPPER=$PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: MANIFEST_ENTRY_JSON_AWK=$MANIFEST_ENTRY_JSON_AWK" 1>&2
|
||||
echo "$0: debug[3]: YEAR_DIR=$YEAR_DIR" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_DIR=$ENTRY_DIR" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_ID=$ENTRY_ID" 1>&2
|
||||
@@ -451,9 +480,9 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: DOT_PATH=$DOT_PATH" 1>&2
|
||||
echo "$0: debug[3]: DOT_PATH_CONTENT=$DOT_PATH_CONTENT" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_JSON=$ENTRY_JSON" 1>&2
|
||||
echo "$0: debug[3]: MANIFEST_ENTRY_JSON_AWK=$MANIFEST_ENTRY_JSON_AWK" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# If -N, time to exit
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -463,6 +492,7 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary markdown for pandoc to process
|
||||
#
|
||||
export TMP_FILE=".tmp.$NAME.FILE.$$.tmp"
|
||||
@@ -485,6 +515,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary markdown file is not used: $TMP_FILE" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary manifest file
|
||||
#
|
||||
export TMP_MANIFEST=".tmp.$NAME.MANIFEST.$$.tmp"
|
||||
@@ -507,6 +538,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary manifest file is not used: $TMP_MANIFEST" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# generate the temporary manifest file
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -542,6 +574,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary manifest markdown is NOT written into: $TMP_FILE" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# convert temporary markdown file into HTML
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -562,6 +595,7 @@ elif [[ $V_FLAG -ge 1 ]]; then
|
||||
echo "$0: debug[1]: -n disabled execution of: $PANDOC_WRAPPER $TMP_FILE -" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
|
||||
+59
-25
@@ -53,6 +53,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -96,6 +97,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -108,6 +110,7 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.4.4 2024-08-05"
|
||||
@@ -131,12 +134,12 @@ export REPO_TOP_URL="https://github.com/ioccc-src/temp-test-ioccc"
|
||||
# GitHub puts individual files under the "blob/master" sub-directory.
|
||||
export REPO_URL="$REPO_TOP_URL/blob/master"
|
||||
export SITE_URL="https://ioccc-src.github.io/temp-test-ioccc"
|
||||
export PANDOC_WRAPPER="bin/pandoc-wrapper.sh"
|
||||
|
||||
|
||||
# set usage message
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N]
|
||||
[-p tool] [-U URL] [-w site_url] [-e string ..] [-E exitcode]
|
||||
[-U URL] [-w site_url] [-e string ..] [-E exitcode]
|
||||
YYYY [more_options]
|
||||
|
||||
-h print help message and exit
|
||||
@@ -150,8 +153,6 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N]
|
||||
-n go thru the actions, but do not update any files (def: do the action)
|
||||
-N do not process file, just parse arguments and ignore the file (def: process the file)
|
||||
|
||||
-p tool run 'pandoc wrapper tool' (not pandoc path) during HTML phase number 21 (def: use $PANDOC_WRAPPER)
|
||||
|
||||
-U url URL of HTML file being formed (def: $URL)
|
||||
-w site_url Base URL of the website (def: $SITE_URL)
|
||||
|
||||
@@ -174,16 +175,11 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# output_award
|
||||
#
|
||||
# Write the award name to standard output (stdout)
|
||||
#
|
||||
# XXX - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XXX
|
||||
# XXX - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - XXX
|
||||
# XXX - until we have the jnamval command, we must FAKE PARSE the .entry.json file - XXX
|
||||
# XXX - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - XXX
|
||||
# XXX - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XXX
|
||||
#
|
||||
# usage:
|
||||
# output_award YYYY/dir/.entry.json
|
||||
#
|
||||
@@ -194,7 +190,6 @@ $NAME version: $VERSION"
|
||||
function output_award
|
||||
{
|
||||
local ENTRY_JSON_PATH; # the .entry.json path
|
||||
local AWARD_STRING; # winning entry award string
|
||||
|
||||
# parse args
|
||||
#
|
||||
@@ -218,15 +213,11 @@ function output_award
|
||||
|
||||
# obtain the award string
|
||||
#
|
||||
AWARD_STRING=$(grep -F '"award" : "' "$ENTRY_JSON_PATH" | sed -e 's/^.*"award" : "//' -e 's/",//')
|
||||
if [[ -z $AWARD_STRING ]]; then
|
||||
echo "$0: ERROR: in output_award: no award found in .entry.json file: $ENTRY_JSON_PATH" 1>&2
|
||||
return 5
|
||||
fi
|
||||
echo "$AWARD_STRING"
|
||||
"$JVAL_WRAPPER" -w -b "$ENTRY_JSON_PATH" '$..award'
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# output_ordinal
|
||||
#
|
||||
# Write the numerical ordinal form of a non-negative integer to standard output (stdout)
|
||||
@@ -288,14 +279,16 @@ function output_ordinal
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# setup
|
||||
#
|
||||
export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNp:U:w:e:E: flag; do
|
||||
while getopts :hv:Vd:D:nNU:w:e:E: flag; do
|
||||
case "$flag" in
|
||||
h) echo "$USAGE" 1>&2
|
||||
exit 2
|
||||
@@ -322,8 +315,6 @@ while getopts :hv:Vd:D:nNp:U:w:e:E: flag; do
|
||||
;;
|
||||
N) DO_NOT_PROCESS="-N"
|
||||
;;
|
||||
p) PANDOC_WRAPPER="$OPTARG"
|
||||
;;
|
||||
U) URL="$OPTARG"
|
||||
;;
|
||||
w) SITE_URL="$OPTARG"
|
||||
@@ -349,7 +340,7 @@ while getopts :hv:Vd:D:nNp:U:w:e:E: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# parse the command line arguments
|
||||
#
|
||||
if [[ $V_FLAG -ge 1 ]]; then
|
||||
@@ -372,6 +363,7 @@ if [[ -z $YYYY ]]; then
|
||||
exit 3
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -392,6 +384,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -415,21 +408,51 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
# verify we have the pandoc wrapper
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
if [[ ! -d $BIN_PATH ]]; then
|
||||
echo "$0: ERROR: bin is not a directory under topdir: $BIN_PATH" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
|
||||
# verify that the bin/pandoc-wrapper.sh tool is executable
|
||||
#
|
||||
export PANDOC_WRAPPER="$BIN_DIR/pandoc-wrapper.sh"
|
||||
if [[ ! -e $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: pandoc wrapper tool does not exist: $PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: ERROR: bin/md2html.sh does not exist: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: pandoc wrapper tool is not a file: $PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: ERROR: bin/md2html.sh is not a regular file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: pandoc wrapper tool is not an executable file: $PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: ERROR: bin/md2html.sh is not an executable file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that the bin/jval-wrapper.sh tool is executable
|
||||
#
|
||||
JVAL_WRAPPER="$BIN_DIR/jval-wrapper.sh"
|
||||
if [[ ! -e $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh does not exist: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh is not a regular file: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh is not an executable file: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that YYYY is an entry directory
|
||||
#
|
||||
if [[ ! -d $YYYY ]]; then
|
||||
@@ -441,6 +464,7 @@ if [[ ! -r $YYYY ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# verify we have a non-empty readable .top file
|
||||
#
|
||||
export TOP_FILE=".top"
|
||||
@@ -461,6 +485,7 @@ if [[ ! -s $TOP_FILE ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# verify that YYYY has a non-empty readable .year file
|
||||
#
|
||||
export YEAR_FILE="$YYYY/.year"
|
||||
@@ -481,6 +506,7 @@ if [[ ! -s $YEAR_FILE ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# determine The N-th IOCCC string
|
||||
#
|
||||
LINE_NUM=$(sed -n "/$YYYY/=" "$TOP_FILE" | head -1)
|
||||
@@ -496,6 +522,7 @@ if [[ -z $ORDINAL ]]; then
|
||||
exit 11
|
||||
fi
|
||||
|
||||
|
||||
# parameter debugging
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -519,6 +546,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: ORDINAL=$ORDINAL" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# If -N, time to exit
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -528,6 +556,7 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary markdown for pandoc to process
|
||||
#
|
||||
export TMP_FILE=".tmp.$NAME.FILE.$$.tmp"
|
||||
@@ -550,6 +579,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary markdown file is not used: $TMP_FILE" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# output leading markdown for this IOCCC year
|
||||
#
|
||||
{
|
||||
@@ -568,6 +598,7 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# process each entry under YYYY
|
||||
#
|
||||
export YYYY_DIR
|
||||
@@ -658,6 +689,7 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# write trailing markdown for this IOCCC year
|
||||
#
|
||||
{
|
||||
@@ -674,6 +706,7 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# convert temporary markdown file into HTML
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -694,6 +727,7 @@ elif [[ $V_FLAG -ge 1 ]]; then
|
||||
echo "$0: debug[1]: -n disabled execution of: $PANDOC_WRAPPER $TMP_FILE -" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
|
||||
+18
-14
@@ -42,6 +42,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -85,6 +86,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -97,6 +99,7 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.7.2 2024-08-05"
|
||||
@@ -140,6 +143,7 @@ export REPO_TOP_URL="https://github.com/ioccc-src/temp-test-ioccc"
|
||||
# GitHub puts individual files under the "blob/master" sub-directory.
|
||||
export REPO_URL="$REPO_TOP_URL/blob/master"
|
||||
|
||||
|
||||
# set usage message
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N]
|
||||
@@ -178,14 +182,16 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# setup
|
||||
#
|
||||
export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:nNp:e:E: flag; do
|
||||
while getopts :hv:Vd:nNe:E: flag; do
|
||||
case "$flag" in
|
||||
h) echo "$USAGE" 1>&2
|
||||
exit 2
|
||||
@@ -201,8 +207,6 @@ while getopts :hv:Vd:nNp:e:E: flag; do
|
||||
;;
|
||||
N) DO_NOT_PROCESS="-N"
|
||||
;;
|
||||
p) PANDOC_TOOL="$OPTARG"
|
||||
;;
|
||||
e) echo "$OPTARG" 1>&2
|
||||
;;
|
||||
E) exit "$OPTARG"
|
||||
@@ -224,7 +228,7 @@ while getopts :hv:Vd:nNp:e:E: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# parse the command line arguments
|
||||
#
|
||||
if [[ $V_FLAG -ge 1 ]]; then
|
||||
@@ -244,6 +248,7 @@ fi
|
||||
export MARKDOWN_INPUT="$1"
|
||||
export HTML_OUTPUT="$2"
|
||||
|
||||
|
||||
# firewall - validate args
|
||||
#
|
||||
if [[ ! -e $MARKDOWN_INPUT ]]; then
|
||||
@@ -265,6 +270,7 @@ fi
|
||||
PANDOC_TOOL_VERSION=$("$PANDOC_TOOL" --version | head -1 | awk '{print $2;}')
|
||||
export PANDOC_TOOL_VERSION
|
||||
|
||||
|
||||
# set the minimum pandoc version
|
||||
#
|
||||
# We have found that very old versions of pandoc, such as version 2.14.0.3,
|
||||
@@ -279,6 +285,7 @@ export PANDOC_TOOL_VERSION
|
||||
#
|
||||
export PANDOC_MIN_VERSION="3.1.12.2"
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -299,6 +306,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -322,6 +330,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have an author subdirectory
|
||||
#
|
||||
export AUTHOR_PATH="$TOPDIR/author"
|
||||
@@ -331,6 +340,7 @@ if [[ ! -d $AUTHOR_PATH ]]; then
|
||||
fi
|
||||
export AUTHOR_DIR="author"
|
||||
|
||||
|
||||
# verify that we have an inc subdirectory
|
||||
#
|
||||
export INC_PATH="$TOPDIR/inc"
|
||||
@@ -340,14 +350,6 @@ if [[ ! -d $INC_PATH ]]; then
|
||||
fi
|
||||
export INC_DIR="inc"
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
if [[ ! -d $BIN_PATH ]]; then
|
||||
echo "$0: ERROR: bin is not a directory under topdir: $BIN_PATH" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# parameter debugging
|
||||
#
|
||||
@@ -377,10 +379,9 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: AUTHOR_DIR=$AUTHOR_DIR" 1>&2
|
||||
echo "$0: debug[3]: INC_PATH=$INC_PATH" 1>&2
|
||||
echo "$0: debug[3]: INC_DIR=$INC_DIR" 1>&2
|
||||
echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2
|
||||
echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# If -N, time to exit
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -390,6 +391,7 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# verify that the pandoc version is >= the minimum version
|
||||
#
|
||||
FIRST_VERSION=$(printf "%s\n%s" "$PANDOC_TOOL_VERSION" "$PANDOC_MIN_VERSION" | LC_ALL=C sort -V | head -1)
|
||||
@@ -402,6 +404,7 @@ if [[ $FIRST_VERSION != "$PANDOC_MIN_VERSION" ]]; then
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# execute pandoc
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -428,6 +431,7 @@ if [[ $status -ne 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
exit 0
|
||||
+73
-20
@@ -35,6 +35,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -78,6 +79,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -90,9 +92,10 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.1.7 2024-08-05"
|
||||
export VERSION="1.2 2024-08-17"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -118,8 +121,6 @@ export DOCROOT_SLASH="../../"
|
||||
# instead of the slightly-slower "bin/readme2index.sh" tool.
|
||||
#
|
||||
export TAGLINE="bin/readme2index.sh"
|
||||
export MD2HTML_SH="bin/md2html.sh"
|
||||
export PANDOC_WRAPPER="bin/pandoc-wrapper.sh"
|
||||
export REPO_TOP_URL="https://github.com/ioccc-src/temp-test-ioccc"
|
||||
# GitHub puts individual files under the "blob/master" sub-directory.
|
||||
export REPO_URL="$REPO_TOP_URL/blob/master"
|
||||
@@ -129,15 +130,17 @@ export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
export EXIT_CODE="0"
|
||||
|
||||
|
||||
# clear options we will add to tools
|
||||
#
|
||||
unset TOOL_OPTION
|
||||
declare -ag TOOL_OPTION
|
||||
|
||||
|
||||
# usage
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
[-t tagline] [-T md2html.sh] [-p tool] [-w site_url]
|
||||
[-t tagline] [-w site_url]
|
||||
tool [more_options]
|
||||
|
||||
-h print help message and exit
|
||||
@@ -154,9 +157,6 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
-N do not process anything, just parse arguments (def: process something)
|
||||
|
||||
-t tagline string to write about the tool that formed the markdown content (def: $TAGLINE)
|
||||
-T md2html.sh run 'markdown to html tool' to convert markdown into HTML (def: $MD2HTML_SH)
|
||||
|
||||
-p tool run 'pandoc wrapper tool' (not pandoc path) during HTML phase number 21 (def: use $PANDOC_WRAPPER)
|
||||
|
||||
-w site_url Base URL of the website (def: $SITE_URL)
|
||||
NOTE: The '-w site_url' is passed as leading options on tool command lines.
|
||||
@@ -164,7 +164,7 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
tool the tool to run over all entries
|
||||
[more_options] additional tool command line options to use before the YYYY/dir argument
|
||||
|
||||
NOTE: Any '-t tagline', '-T md2html.sh', '-p tool', '-w site_url'
|
||||
NOTE: Any '-t tagline', '-w site_url'
|
||||
are passed to the 'tool' at the beginning of the command line, and
|
||||
before any optional 'more_options' and before the final YYYY/dir argument.
|
||||
|
||||
@@ -181,9 +181,10 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNt:T:p:w: flag; do
|
||||
while getopts :hv:Vd:D:nNt:w: flag; do
|
||||
case "$flag" in
|
||||
h) echo "$USAGE" 1>&2
|
||||
exit 2
|
||||
@@ -232,14 +233,6 @@ while getopts :hv:Vd:D:nNt:T:p:w: flag; do
|
||||
TOOL_OPTION+=("-t")
|
||||
TOOL_OPTION+=("$TAGLINE")
|
||||
;;
|
||||
T) MD2HTML_SH="$OPTARG"
|
||||
TOOL_OPTION+=("-T")
|
||||
TOOL_OPTION+=("$MD2HTML_SH")
|
||||
;;
|
||||
p) PANDOC_WRAPPER="$OPTARG"
|
||||
TOOL_OPTION+=("-p")
|
||||
TOOL_OPTION+=("$PANDOC_WRAPPER")
|
||||
;;
|
||||
w) SITE_URL="$OPTARG"
|
||||
TOOL_OPTION+=("-w")
|
||||
TOOL_OPTION+=("$SITE_URL")
|
||||
@@ -261,7 +254,7 @@ while getopts :hv:Vd:D:nNt:T:p:w: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# remove the options
|
||||
#
|
||||
shift $(( OPTIND - 1 ));
|
||||
@@ -279,6 +272,7 @@ fi
|
||||
#
|
||||
export ENTRY_PATH="$1"
|
||||
|
||||
|
||||
# always add the '-v level' option, unless level is empty, to the set of options passed to the md2html.sh tool
|
||||
#
|
||||
if [[ -n $V_FLAG ]]; then
|
||||
@@ -286,6 +280,7 @@ if [[ -n $V_FLAG ]]; then
|
||||
TOOL_OPTION+=("$V_FLAG")
|
||||
fi
|
||||
|
||||
|
||||
# always add the '-t tagline' option, unless tagline is empty, to the set of options passed to the md2html.sh tool
|
||||
#
|
||||
if [[ -n $TAGLINE ]]; then
|
||||
@@ -293,6 +288,7 @@ if [[ -n $TAGLINE ]]; then
|
||||
TOOL_OPTION+=("$TAGLINE")
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -313,6 +309,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -336,6 +333,51 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
if [[ ! -d $BIN_PATH ]]; then
|
||||
echo "$0: ERROR: bin is not a directory under topdir: $BIN_PATH" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
|
||||
# verify that the bin/md2html.sh tool is executable
|
||||
#
|
||||
export MD2HTML_SH="$BIN_DIR/md2html.sh"
|
||||
if [[ ! -e $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh does not exist: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not a regular file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not an executable file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that the bin/pandoc-wrapper.sh tool is executable
|
||||
#
|
||||
export PANDOC_WRAPPER="$BIN_DIR/pandoc-wrapper.sh"
|
||||
if [[ ! -e $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh does not exist: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not a regular file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not an executable file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that ENTRY_PATH is a entry directory
|
||||
#
|
||||
if [[ ! -d $ENTRY_PATH ]]; then
|
||||
@@ -409,6 +451,7 @@ if [[ ! -r $ENTRY_JSON ]]; then
|
||||
exit 7
|
||||
fi
|
||||
|
||||
|
||||
# verify that the md2html tool is executable
|
||||
#
|
||||
if [[ ! -e $MD2HTML_SH ]]; then
|
||||
@@ -424,6 +467,7 @@ if [[ ! -x $MD2HTML_SH ]]; then
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# setup README_PATH and INDEX_PATH using YYYY_DIR
|
||||
#
|
||||
export README_PATH="$YYYY_DIR/README.md"
|
||||
@@ -445,6 +489,7 @@ if [[ ! -s $README_PATH ]]; then
|
||||
exit 7
|
||||
fi
|
||||
|
||||
|
||||
# verify that .entry.json is a non-empty readable file
|
||||
#
|
||||
export ENTRY_JSON="$YYYY_DIR/.entry.json"
|
||||
@@ -465,11 +510,13 @@ if [[ ! -s $ENTRY_JSON ]]; then
|
||||
exit 7
|
||||
fi
|
||||
|
||||
|
||||
# always add the '-U URL' for the entry's index.html file
|
||||
#
|
||||
TOOL_OPTION+=("-U")
|
||||
TOOL_OPTION+=("$SITE_URL/$YYYY_DIR/index.html")
|
||||
|
||||
|
||||
# print running info if verbose
|
||||
#
|
||||
# If -v 3 or higher, print exported variables in order that they were exported.
|
||||
@@ -483,8 +530,6 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: DOCROOT_SLASH=$DOCROOT_SLASH" 1>&2
|
||||
echo "$0: debug[3]: TAGLINE=$TAGLINE" 1>&2
|
||||
echo "$0: debug[3]: TAGLINE=$TAGLINE" 1>&2
|
||||
echo "$0: debug[3]: MD2HTML_SH=$MD2HTML_SH" 1>&2
|
||||
echo "$0: debug[3]: PANDOC_WRAPPER=$PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: REPO_TOP_URL=$REPO_TOP_URL" 1>&2
|
||||
echo "$0: debug[3]: REPO_URL=$REPO_URL" 1>&2
|
||||
echo "$0: debug[3]: SITE_URL=$SITE_URL" 1>&2
|
||||
@@ -497,6 +542,10 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: ENTRY_PATH=$ENTRY_PATH" 1>&2
|
||||
echo "$0: debug[3]: REPO_NAME=$REPO_NAME" 1>&2
|
||||
echo "$0: debug[3]: CD_FAILED=$CD_FAILED" 1>&2
|
||||
echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2
|
||||
echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2
|
||||
echo "$0: debug[3]: MD2HTML_SH=$MD2HTML_SH" 1>&2
|
||||
echo "$0: debug[3]: PANDOC_WRAPPER=$PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: YEAR_DIR=$YEAR_DIR" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_DIR=$ENTRY_DIR" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_ID=$ENTRY_ID" 1>&2
|
||||
@@ -510,6 +559,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: ENTRY_JSON=$ENTRY_JSON" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# -N stops early before any processing is performed
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -519,6 +569,7 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# determine if we need to run the tool
|
||||
#
|
||||
# Check if the non-empty index.html is newer than both README.md and .entry.json files.
|
||||
@@ -535,6 +586,7 @@ if [[ -s $INDEX_PATH && $INDEX_PATH -nt $ENTRY_JSON && $INDEX_PATH -nt $README_P
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# run the md2html.sh tool, unless -n
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -575,6 +627,7 @@ elif [[ $V_FLAG -ge 5 ]]; then
|
||||
"$README_PATH $INDEX_PATH" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
if [[ $EXIT_CODE -ne 0 ]]; then
|
||||
|
||||
+69
-36
@@ -29,6 +29,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -72,6 +73,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -84,9 +86,10 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.2.7 2024-08-05"
|
||||
export VERSION="1.3 2024-08-17"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -104,8 +107,6 @@ fi
|
||||
export TOPDIR
|
||||
export DOCROOT_SLASH="../../"
|
||||
export TAGLINE="bin/$NAME"
|
||||
export MD2HTML_SH="bin/md2html.sh"
|
||||
export PANDOC_WRAPPER="bin/pandoc-wrapper.sh"
|
||||
export REPO_TOP_URL="https://github.com/ioccc-src/temp-test-ioccc"
|
||||
# GitHub puts individual files under the "blob/master" sub-directory.
|
||||
export REPO_URL="$REPO_TOP_URL/blob/master"
|
||||
@@ -115,16 +116,17 @@ export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
export EXIT_CODE="0"
|
||||
|
||||
|
||||
# clear options we will add to tools
|
||||
#
|
||||
unset TOOL_OPTION
|
||||
declare -ag TOOL_OPTION
|
||||
|
||||
|
||||
# usage
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
[-t tagline] [-T md2html.sh] [-p tool]
|
||||
[-w site_url] [-e string ..] [-E exitcode]
|
||||
[-t tagline] [-w site_url] [-e string ..] [-E exitcode]
|
||||
YYYY/dir
|
||||
|
||||
-h print help message and exit
|
||||
@@ -143,11 +145,6 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
|
||||
-t tagline string to write about the tool that formed the markdown content (def: $TAGLINE)
|
||||
NOTE: 'tagline' may be enclosed within, but may NOT contain an internal single-quote, or double-quote.
|
||||
-T md2html.sh run 'markdown to html tool' to convert markdown into HTML (def: $MD2HTML_SH)
|
||||
|
||||
-p tool run 'pandoc wrapper tool' (not pandoc path) during HTML phase number 21 (def: use $PANDOC_WRAPPER)
|
||||
-p . skip HTML phase number 21 (def: do nothing during HTML phase number 21)
|
||||
NOTE: The '-p tool' will be passed as leading options on the -b tool and -a tool command lines.
|
||||
|
||||
-w site_url Base URL of the website (def: $SITE_URL)
|
||||
NOTE: The '-w site_url' is passed as leading options on tool command lines.
|
||||
@@ -156,7 +153,7 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
|
||||
NOTE: The '-v level' is passed as initial command line options to the 'markdown to html tool' (md2html.sh).
|
||||
The 'tagline' is passed as '-t tagline' to the 'markdown to html tool' (md2html.sh), after the '-v level'.
|
||||
Any '-T md2html.sh', '-p tool', '-P pandoc_opts', '-U top_url'
|
||||
Any '-P pandoc_opts', '-U top_url'
|
||||
are passed to the 'markdown to html tool' (md2html.sh), and will be before any command line arguments.
|
||||
|
||||
Exit codes:
|
||||
@@ -172,9 +169,10 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNt:T:p:w: flag; do
|
||||
while getopts :hv:Vd:D:nNt:w: flag; do
|
||||
case "$flag" in
|
||||
h) echo "$USAGE" 1>&2
|
||||
exit 2
|
||||
@@ -225,14 +223,6 @@ while getopts :hv:Vd:D:nNt:T:p:w: flag; do
|
||||
TOOL_OPTION+=("-t")
|
||||
TOOL_OPTION+=("$TAGLINE")
|
||||
;;
|
||||
T) MD2HTML_SH="$OPTARG"
|
||||
TOOL_OPTION+=("-T")
|
||||
TOOL_OPTION+=("$MD2HTML_SH")
|
||||
;;
|
||||
p) PANDOC_WRAPPER="$OPTARG"
|
||||
TOOL_OPTION+=("-p")
|
||||
TOOL_OPTION+=("$PANDOC_WRAPPER")
|
||||
;;
|
||||
w) SITE_URL="$OPTARG"
|
||||
TOOL_OPTION+=("-w")
|
||||
TOOL_OPTION+=("$SITE_URL")
|
||||
@@ -254,7 +244,7 @@ while getopts :hv:Vd:D:nNt:T:p:w: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# remove the options
|
||||
#
|
||||
shift $(( OPTIND - 1 ));
|
||||
@@ -272,6 +262,7 @@ fi
|
||||
#
|
||||
export ENTRY_PATH="$1"
|
||||
|
||||
|
||||
# always add the '-v level' option, unless level is empty, to the set of options passed to the md2html.sh tool
|
||||
#
|
||||
if [[ -n $V_FLAG ]]; then
|
||||
@@ -279,6 +270,7 @@ if [[ -n $V_FLAG ]]; then
|
||||
TOOL_OPTION+=("$V_FLAG")
|
||||
fi
|
||||
|
||||
|
||||
# always add the '-t tagline' option, unless tagline is empty, to the set of options passed to the md2html.sh tool
|
||||
#
|
||||
if [[ -n $TAGLINE ]]; then
|
||||
@@ -286,6 +278,7 @@ if [[ -n $TAGLINE ]]; then
|
||||
TOOL_OPTION+=("$TAGLINE")
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -306,6 +299,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -329,6 +323,51 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
if [[ ! -d $BIN_PATH ]]; then
|
||||
echo "$0: ERROR: bin is not a directory under topdir: $BIN_PATH" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
|
||||
# verify that the bin/md2html.sh tool is executable
|
||||
#
|
||||
export MD2HTML_SH="$BIN_DIR/md2html.sh"
|
||||
if [[ ! -e $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh does not exist: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not a regular file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not an executable file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that the bin/pandoc-wrapper.sh tool is executable
|
||||
#
|
||||
export PANDOC_WRAPPER="$BIN_DIR/pandoc-wrapper.sh"
|
||||
if [[ ! -e $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh does not exist: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not a regular file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/md2html.sh is not an executable file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that ENTRY_PATH is a entry directory
|
||||
#
|
||||
if [[ ! -d $ENTRY_PATH ]]; then
|
||||
@@ -389,20 +428,6 @@ if [[ $ENTRY_PATH != "$DOT_PATH_CONTENT" ]]; then
|
||||
exit 7
|
||||
fi
|
||||
|
||||
# verify that the md2html tool is executable
|
||||
#
|
||||
if [[ ! -e $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: md2html.sh does not exist: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: md2html.sh is not a regular file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $MD2HTML_SH ]]; then
|
||||
echo "$0: ERROR: md2html.sh is not an executable file: $MD2HTML_SH" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# setup README_PATH and INDEX_PATH using YYYY_DIR
|
||||
#
|
||||
@@ -425,6 +450,7 @@ if [[ ! -s $README_PATH ]]; then
|
||||
exit 7
|
||||
fi
|
||||
|
||||
|
||||
# verify that .entry.json is a non-empty readable file
|
||||
#
|
||||
export ENTRY_JSON="$YYYY_DIR/.entry.json"
|
||||
@@ -445,11 +471,13 @@ if [[ ! -s $ENTRY_JSON ]]; then
|
||||
exit 7
|
||||
fi
|
||||
|
||||
|
||||
# always add the '-U URL' for the entry's index.html file
|
||||
#
|
||||
TOOL_OPTION+=("-U")
|
||||
TOOL_OPTION+=("$SITE_URL/$YYYY_DIR/index.html")
|
||||
|
||||
|
||||
# print running info if verbose
|
||||
#
|
||||
# If -v 3 or higher, print exported variables in order that they were exported.
|
||||
@@ -463,7 +491,6 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: DOCROOT_SLASH=$DOCROOT_SLASH" 1>&2
|
||||
echo "$0: debug[3]: TAGLINE=$TAGLINE" 1>&2
|
||||
echo "$0: debug[3]: MD2HTML_SH=$MD2HTML_SH" 1>&2
|
||||
echo "$0: debug[3]: PANDOC_WRAPPER=$PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: REPO_TOP_URL=$REPO_TOP_URL" 1>&2
|
||||
echo "$0: debug[3]: REPO_URL=$REPO_URL" 1>&2
|
||||
echo "$0: debug[3]: SITE_URL=$SITE_URL" 1>&2
|
||||
@@ -476,6 +503,9 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: ENTRY_PATH=$ENTRY_PATH" 1>&2
|
||||
echo "$0: debug[3]: REPO_NAME=$REPO_NAME" 1>&2
|
||||
echo "$0: debug[3]: CD_FAILED=$CD_FAILED" 1>&2
|
||||
echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2
|
||||
echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2
|
||||
echo "$0: debug[3]: PANDOC_WRAPPER=$PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: YEAR_DIR=$YEAR_DIR" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_DIR=$ENTRY_DIR" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_ID=$ENTRY_ID" 1>&2
|
||||
@@ -489,6 +519,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: ENTRY_JSON=$ENTRY_JSON" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# -N stops early before any processing is performed
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -498,6 +529,7 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# run the md2html.sh tool, unless -n
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -525,6 +557,7 @@ elif [[ $V_FLAG -ge 5 ]]; then
|
||||
"$README_PATH $INDEX_PATH" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
if [[ $EXIT_CODE -ne 0 ]]; then
|
||||
|
||||
@@ -46,6 +46,9 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# sort .gitignore content on stdin to stdout
|
||||
#
|
||||
sed -e '/^#/s/.*/0 &/' -e '/^*/s/.*/1 &/' -e '/^[^01*!]/s/.*/2 &/' -e '/^!/s/.*/3 &/' |
|
||||
LC_ALL=C sort -u -k 1n -k 2d |
|
||||
sed 's/[0123] //'
|
||||
+26
-10
@@ -41,6 +41,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -97,6 +98,7 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.1.8 2024-07-28"
|
||||
@@ -119,7 +121,7 @@ export REPO_TOP_URL="https://github.com/ioccc-src/temp-test-ioccc"
|
||||
# GitHub puts individual files under the "blob/master" sub-directory.
|
||||
export REPO_URL="$REPO_TOP_URL/blob/master"
|
||||
export TOP_URL="https://ioccc-src.github.io/temp-test-ioccc"
|
||||
export SGI_TOOL="bin/sgi.sh"
|
||||
|
||||
|
||||
# set usage message
|
||||
#
|
||||
@@ -150,11 +152,13 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# setup
|
||||
#
|
||||
export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:nN flag; do
|
||||
@@ -190,7 +194,7 @@ while getopts :hv:Vd:nN flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# parse the command line arguments
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -209,6 +213,7 @@ fi
|
||||
#
|
||||
export ENTRY_PATH="$1"
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -229,6 +234,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -252,6 +258,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
@@ -261,21 +268,24 @@ if [[ ! -d $BIN_PATH ]]; then
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# verify we have an executable sgi.sh tool
|
||||
|
||||
# verify that the bin/sgi.sh tool is executable
|
||||
#
|
||||
if [[ ! -e $SGI_TOOL ]]; then
|
||||
echo "$0: ERROR: sgi.sh tool does not exist: $SGI_TOOL" 1>&2
|
||||
export SGI_TOOL="$BIN_DIR/sgi.sh"
|
||||
if [[ ! -e $SGI_TOOL.sh ]]; then
|
||||
echo "$0: ERROR: bin/sgi.sh does not exist: $SGI_TOOL.sh" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $SGI_TOOL ]]; then
|
||||
echo "$0: ERROR: sgi.sh tool is not a file: $SGI_TOOL" 1>&2
|
||||
if [[ ! -f $SGI_TOOL.sh ]]; then
|
||||
echo "$0: ERROR: bin/sgi.sh is not a regular file: $SGI_TOOL.sh" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $SGI_TOOL ]]; then
|
||||
echo "$0: ERROR: sgi.sh tool is not an executable file: $SGI_TOOL" 1>&2
|
||||
if [[ ! -x $SGI_TOOL.sh ]]; then
|
||||
echo "$0: ERROR: bin/sgi.sh is not an executable file: $SGI_TOOL.sh" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that ENTRY_PATH is a entry directory
|
||||
#
|
||||
if [[ ! -d $ENTRY_PATH ]]; then
|
||||
@@ -349,6 +359,7 @@ if [[ ! -r $ENTRY_JSON ]]; then
|
||||
exit 7
|
||||
fi
|
||||
|
||||
|
||||
# verify .gitignore
|
||||
#
|
||||
export GITIGNORE="$YEAR_DIR/$ENTRY_DIR/.gitignore"
|
||||
@@ -365,6 +376,7 @@ if [[ ! -w $GITIGNORE ]]; then
|
||||
exit 7
|
||||
fi
|
||||
|
||||
|
||||
# parameter debugging
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -376,7 +388,6 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: REPO_TOP_URL=$REPO_TOP_URL" 1>&2
|
||||
echo "$0: debug[3]: REPO_URL=$REPO_URL" 1>&2
|
||||
echo "$0: debug[3]: TOP_URL=$TOP_URL" 1>&2
|
||||
echo "$0: debug[3]: SGI_TOOL=$SGI_TOOL" 1>&2
|
||||
echo "$0: debug[3]: NOOP=$NOOP" 1>&2
|
||||
echo "$0: debug[3]: DO_NOT_PROCESS=$DO_NOT_PROCESS" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_PATH=$ENTRY_PATH" 1>&2
|
||||
@@ -384,6 +395,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: CD_FAILED=$CD_FAILED" 1>&2
|
||||
echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2
|
||||
echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2
|
||||
echo "$0: debug[3]: SGI_TOOL=$SGI_TOOL" 1>&2
|
||||
echo "$0: debug[3]: YEAR_DIR=$YEAR_DIR" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_DIR=$ENTRY_DIR" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_ID=$ENTRY_ID" 1>&2
|
||||
@@ -395,6 +407,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: GITIGNORE=$GITIGNORE" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# If -N, time to exit
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -404,6 +417,7 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary markdown for pandoc to process
|
||||
#
|
||||
export TMP_FILE="$ENTRY_PATH/.tmp.$NAME.FILE.$$.tmp"
|
||||
@@ -426,6 +440,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary markdown file is not used: $TMP_FILE" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# convert temporary markdown file into HTML
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -458,6 +473,7 @@ elif [[ $V_FLAG -ge 1 ]]; then
|
||||
echo "$0: debug[1]: -n disabled execution of: mv -f $TMP_FILE $GITIGNORE" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
|
||||
+27
-14
@@ -44,6 +44,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -87,6 +88,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -99,6 +101,7 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.4.3 2024-08-05"
|
||||
@@ -118,17 +121,17 @@ if [[ $status -eq 0 ]]; then
|
||||
fi
|
||||
export TOPDIR
|
||||
export DOCROOT_SLASH="./"
|
||||
export PANDOC_WRAPPER="bin/pandoc-wrapper.sh"
|
||||
export REPO_TOP_URL="https://github.com/ioccc-src/temp-test-ioccc"
|
||||
# GitHub puts individual files under the "blob/master" sub-directory.
|
||||
export REPO_URL="$REPO_TOP_URL/blob/master"
|
||||
export SITE_URL="https://ioccc-src.github.io/temp-test-ioccc"
|
||||
export URL="#"
|
||||
|
||||
|
||||
# set usage message
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
[-p tool] [-U url] [-w site_url] [-e string ..] [-E exitcode]
|
||||
[-U url] [-w site_url] [-e string ..] [-E exitcode]
|
||||
|
||||
-h print help message and exit
|
||||
-v level set verbosity level (def level: 0)
|
||||
@@ -141,8 +144,6 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
-n go thru the actions, but do not update any files (def: do the action)
|
||||
-N do not process file, just parse arguments and ignore the file (def: process the file)
|
||||
|
||||
-p tool run 'pandoc wrapper tool' (not pandoc path) during HTML phase number 21 (def: use $PANDOC_WRAPPER)
|
||||
|
||||
-U url URL of HTML file being formed (def: $URL)
|
||||
-w site_url Base URL of the website (def: $SITE_URL)
|
||||
|
||||
@@ -163,14 +164,16 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# setup
|
||||
#
|
||||
export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNp:U:w:e:E: flag; do
|
||||
while getopts :hv:Vd:D:nNU:w:e:E: flag; do
|
||||
case "$flag" in
|
||||
h) echo "$USAGE" 1>&2
|
||||
exit 2
|
||||
@@ -197,8 +200,6 @@ while getopts :hv:Vd:D:nNp:U:w:e:E: flag; do
|
||||
;;
|
||||
N) DO_NOT_PROCESS="-N"
|
||||
;;
|
||||
p) PANDOC_WRAPPER="$OPTARG"
|
||||
;;
|
||||
U) URL="$OPTARG"
|
||||
;;
|
||||
w) SITE_URL="$OPTARG"
|
||||
@@ -224,7 +225,7 @@ while getopts :hv:Vd:D:nNp:U:w:e:E: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# parse the command line arguments
|
||||
#
|
||||
if [[ $V_FLAG -ge 1 ]]; then
|
||||
@@ -244,6 +245,7 @@ if [[ $V_FLAG -ge 5 ]]; then
|
||||
echo "$0: debug[5]: arg: $1" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -264,6 +266,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -287,8 +290,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
if [[ ! -d $BIN_PATH ]]; then
|
||||
echo "$0: ERROR: bin is not a directory under topdir: $BIN_PATH" 1>&2
|
||||
@@ -296,21 +298,24 @@ if [[ ! -d $BIN_PATH ]]; then
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# verify pandoc wrapper tool
|
||||
|
||||
# verify that the bin/pandoc-wrapper.sh tool is executable
|
||||
#
|
||||
export PANDOC_WRAPPER="$BIN_DIR/pandoc-wrapper.sh"
|
||||
if [[ ! -e $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: pandoc wrapper tool does not exist: $PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: ERROR: bin/md2html.sh does not exist: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: pandoc wrapper tool is not a file: $PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: ERROR: bin/md2html.sh is not a regular file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: pandoc wrapper tool is not an executable file: $PANDOC_WRAPPER" 1>&2
|
||||
echo "$0: ERROR: bin/md2html.sh is not an executable file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify status.json file
|
||||
#
|
||||
export STATUS_JSON="status.json"
|
||||
@@ -331,6 +336,7 @@ if [[ ! -s $STATUS_JSON ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# parameter debugging
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -354,6 +360,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: STATUS_JSON=$STATUS_JSON" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# If -N, time to exit
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -363,6 +370,7 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary markdown for pandoc to process
|
||||
#
|
||||
export TMP_FILE=".tmp.$NAME.FILE.$$.tmp"
|
||||
@@ -385,6 +393,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary markdown file is not used: $TMP_FILE" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# obtain the contest_status from status.json
|
||||
#
|
||||
CONTEST_STATUS=$(grep '"contest_status"\s*:\s*"[^"][^"]*"' "$STATUS_JSON" | sed -e 's/",\s*$//' -e 's/^.*"//')
|
||||
@@ -395,6 +404,7 @@ if [[ $status -ne 0 || -z $CONTEST_STATUS ]]; then
|
||||
exit 8
|
||||
fi
|
||||
|
||||
|
||||
# validate and normalize the contest_status cfrom status.json
|
||||
#
|
||||
case "$CONTEST_STATUS" in
|
||||
@@ -413,6 +423,7 @@ c|closed) CONTEST_STATUS="closed"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# write temporary markdown file for status.json
|
||||
#
|
||||
{
|
||||
@@ -483,6 +494,7 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# convert temporary markdown file into HTML
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -503,6 +515,7 @@ elif [[ $V_FLAG -ge 1 ]]; then
|
||||
echo "$0: debug[1]: -n disabled execution of: $PANDOC_WRAPPER $TMP_FILE -" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
|
||||
+15
-1
@@ -35,6 +35,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -78,6 +79,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -90,6 +92,7 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.3.2 2024-08-05"
|
||||
@@ -115,6 +118,7 @@ export REPO_URL="$REPO_TOP_URL/blob/master"
|
||||
export SITE_URL="https://ioccc-src.github.io/temp-test-ioccc"
|
||||
export URL="#"
|
||||
|
||||
|
||||
# set usage message
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
@@ -151,11 +155,13 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# setup
|
||||
#
|
||||
export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNU:w:e:E: flag; do
|
||||
@@ -210,7 +216,7 @@ while getopts :hv:Vd:D:nNU:w:e:E: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# parse the command line arguments
|
||||
#
|
||||
if [[ $V_FLAG -ge 1 ]]; then
|
||||
@@ -223,11 +229,13 @@ if [[ $V_FLAG -ge 5 ]]; then
|
||||
echo "$0: debug[5]: file argument count: $#" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# form Nu Html Checker doc url string
|
||||
#
|
||||
VALIDATOR_ENCODED_URL=$(echo "$URL" | sed -e 's;/;%2F;g' -e 's;:;%3A;')
|
||||
export VALIDATOR_ENCODED_URL
|
||||
|
||||
|
||||
# parameter debugging
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -246,6 +254,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: VALIDATOR_ENCODED_URL=$VALIDATOR_ENCODED_URL" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# If -N, time to exit
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -255,27 +264,32 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# output HEADER_1 substitution
|
||||
#
|
||||
echo "-s"
|
||||
echo "HEADER_1=The International Obfuscated C Code Contest"
|
||||
|
||||
|
||||
# output REPO_URL substitution
|
||||
#
|
||||
echo "-s"
|
||||
echo "REPO_URL=$REPO_URL"
|
||||
|
||||
|
||||
# output SITE_URL substitution
|
||||
#
|
||||
echo "-s"
|
||||
echo "SITE_URL=$SITE_URL"
|
||||
|
||||
|
||||
# output DOCROOT_SLASH substitution
|
||||
#
|
||||
echo "-s"
|
||||
echo "DOCROOT_SLASH=$DOCROOT_SLASH"
|
||||
export VALIDATOR_ENCODED_URL
|
||||
|
||||
|
||||
# output the Validator encoded URL
|
||||
#
|
||||
echo "-s"
|
||||
|
||||
+54
-26
@@ -46,6 +46,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -89,6 +90,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -101,6 +103,7 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.5 2024-08-13"
|
||||
@@ -125,6 +128,7 @@ export REPO_TOP_URL="https://github.com/ioccc-src/temp-test-ioccc"
|
||||
export REPO_URL="$REPO_TOP_URL/blob/master"
|
||||
export SITE_URL="https://ioccc-src.github.io/temp-test-ioccc"
|
||||
|
||||
|
||||
# set usage message
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N]
|
||||
@@ -163,14 +167,9 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# Write the award name to standard output (stdout)
|
||||
#
|
||||
# XXX - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XXX
|
||||
# XXX - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - XXX
|
||||
# XXX - until we have the jnamval command, we must FAKE PARSE the .entry.json file - XXX
|
||||
# XXX - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - GROSS HACK - XXX
|
||||
# XXX - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XXX
|
||||
#
|
||||
# usage:
|
||||
# output_award YYYY/dir/.entry.json
|
||||
#
|
||||
@@ -208,11 +207,13 @@ function output_award
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# setup
|
||||
#
|
||||
export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNU:w:e:E: flag; do
|
||||
@@ -268,6 +269,7 @@ while getopts :hv:Vd:D:nNU:w:e:E: flag; do
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
# parse the command line arguments
|
||||
#
|
||||
if [[ $V_FLAG -ge 1 ]]; then
|
||||
@@ -286,6 +288,7 @@ fi
|
||||
#
|
||||
export ENTRY_PATH="$1"
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -306,6 +309,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -329,6 +333,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have an author subdirectory
|
||||
#
|
||||
export AUTHOR_PATH="$TOPDIR/author"
|
||||
@@ -338,6 +343,7 @@ if [[ ! -d $AUTHOR_PATH ]]; then
|
||||
fi
|
||||
export AUTHOR_DIR="author"
|
||||
|
||||
|
||||
# verify that we have an inc subdirectory
|
||||
#
|
||||
export INC_PATH="$TOPDIR/inc"
|
||||
@@ -347,6 +353,7 @@ if [[ ! -d $INC_PATH ]]; then
|
||||
fi
|
||||
export INC_DIR="inc"
|
||||
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
@@ -356,13 +363,40 @@ if [[ ! -d $BIN_PATH ]]; then
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# find the jval-wrapper.sh tool
|
||||
|
||||
# verify that the bin/jval-wrapper.sh tool is executable
|
||||
#
|
||||
JVAL_WRAPPER="$BIN_PATH/jval-wrapper.sh"
|
||||
if [[ ! -x $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: cannot find the bin/jval-wrapper.sh executable" 1>&2
|
||||
JVAL_WRAPPER="$BIN_DIR/jval-wrapper.sh"
|
||||
if [[ ! -e $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh does not exist: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh is not a regular file: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: bin/jval-wrapper.sh is not an executable file: $JVAL_WRAPPER" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify we have our awk script
|
||||
#
|
||||
export ENTRY_NAVBAR_AWK="$BIN_DIR/subst.entry-navbar.awk"
|
||||
if [[ ! -e $ENTRY_NAVBAR_AWK ]]; then
|
||||
echo "$0: ERROR: bin/subst.entry-navbar.awk does not exist: $ENTRY_NAVBAR_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $ENTRY_NAVBAR_AWK ]]; then
|
||||
echo "$0: ERROR: bin/subst.entry-navbar.awk is not a file: $ENTRY_NAVBAR_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -r $ENTRY_NAVBAR_AWK ]]; then
|
||||
echo "$0: ERROR: bin/subst.entry-navbar.awk is not a readable file: $ENTRY_NAVBAR_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that ENTRY_PATH is a entry directory
|
||||
#
|
||||
@@ -437,21 +471,6 @@ if [[ ! -r $ENTRY_JSON ]]; then
|
||||
exit 7
|
||||
fi
|
||||
|
||||
# verify we have our awk script
|
||||
#
|
||||
export ENTRY_NAVBAR_AWK="$BIN_DIR/subst.entry-navbar.awk"
|
||||
if [[ ! -e $ENTRY_NAVBAR_AWK ]]; then
|
||||
echo "$0: ERROR: bin/subst.entry-navbar.awk does not exist: $ENTRY_NAVBAR_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $ENTRY_NAVBAR_AWK ]]; then
|
||||
echo "$0: ERROR: bin/subst.entry-navbar.awk is not a file: $ENTRY_NAVBAR_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -r $ENTRY_NAVBAR_AWK ]]; then
|
||||
echo "$0: ERROR: bin/subst.entry-navbar.awk is not a readable file: $ENTRY_NAVBAR_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# determine award
|
||||
#
|
||||
@@ -462,6 +481,7 @@ if [[ -z $AWARD ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# parameter debugging
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -486,6 +506,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2
|
||||
echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2
|
||||
echo "$0: debug[3]: JVAL_WRAPPER=$JVAL_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_JSON=$ENTRY_JSON" 1>&2
|
||||
echo "$0: debug[3]: YEAR_DIR=$YEAR_DIR" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_DIR=$ENTRY_DIR" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_ID=$ENTRY_ID" 1>&2
|
||||
@@ -493,11 +514,11 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: YYYY_DIR=$YYYY_DIR" 1>&2
|
||||
echo "$0: debug[3]: DOT_PATH=$DOT_PATH" 1>&2
|
||||
echo "$0: debug[3]: DOT_PATH_CONTENT=$DOT_PATH_CONTENT" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_JSON=$ENTRY_JSON" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_NAVBAR_AWK=$ENTRY_NAVBAR_AWK" 1>&2
|
||||
echo "$0: debug[3]: AWARD=$AWARD" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# If -N, time to exit
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -507,26 +528,31 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# output TITLE substitution
|
||||
#
|
||||
echo "-s"
|
||||
echo "TITLE=$YYYY_DIR - $AWARD"
|
||||
|
||||
|
||||
# output DESCRIPTION substitution
|
||||
#
|
||||
echo "-s"
|
||||
echo "DESCRIPTION=$YEAR_DIR IOCCC entry $ENTRY_DIR - $AWARD"
|
||||
|
||||
|
||||
# output KEYWORDS substitution
|
||||
#
|
||||
echo "-s"
|
||||
echo "KEYWORDS=IOCCC, $YEAR_DIR, IOCCC $YEAR_DIR, IOCCC entry, $ENTRY_DIR, $AWARD"
|
||||
|
||||
|
||||
# output HEADER_2 substitution
|
||||
#
|
||||
echo "-s"
|
||||
echo "HEADER_2=$YYYY_DIR - $AWARD"
|
||||
|
||||
|
||||
# output navbar left hand side links
|
||||
#
|
||||
awk -v entry_path="$YYYY_DIR" -f "$ENTRY_NAVBAR_AWK" "$DOT_ALLYEAR"
|
||||
@@ -536,6 +562,7 @@ if [[ $status -ne 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# output navbar right hand side links
|
||||
#
|
||||
echo "-s"
|
||||
@@ -558,6 +585,7 @@ echo "INVENTORY_LINK=#inventory"
|
||||
echo "-s"
|
||||
echo "INVENTORY_TEXT=Inventory"
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
exit 0
|
||||
+49
-24
@@ -46,6 +46,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -89,6 +90,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -101,6 +103,7 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.1.5 2024-08-05"
|
||||
@@ -125,6 +128,7 @@ export REPO_TOP_URL="https://github.com/ioccc-src/temp-test-ioccc"
|
||||
export REPO_URL="$REPO_TOP_URL/blob/master"
|
||||
export SITE_URL="https://ioccc-src.github.io/temp-test-ioccc"
|
||||
|
||||
|
||||
# set usage message
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N]
|
||||
@@ -163,6 +167,7 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# output_ordinal
|
||||
#
|
||||
# Write the numerical ordinal form of a non-negative integer to standard output (stdout)
|
||||
@@ -224,11 +229,13 @@ function output_ordinal
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# setup
|
||||
#
|
||||
export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNU:w:e:E: flag; do
|
||||
@@ -283,7 +290,7 @@ while getopts :hv:Vd:D:nNU:w:e:E: flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# parse the command line arguments
|
||||
#
|
||||
if [[ $V_FLAG -ge 1 ]]; then
|
||||
@@ -302,6 +309,7 @@ fi
|
||||
#
|
||||
export YEAR_ARG="$1"
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -322,6 +330,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have an author subdirectory
|
||||
#
|
||||
export AUTHOR_PATH="$TOPDIR/author"
|
||||
@@ -331,6 +340,7 @@ if [[ ! -d $AUTHOR_PATH ]]; then
|
||||
fi
|
||||
export AUTHOR_DIR="author"
|
||||
|
||||
|
||||
# verify that we have an inc subdirectory
|
||||
#
|
||||
export INC_PATH="$TOPDIR/inc"
|
||||
@@ -340,14 +350,6 @@ if [[ ! -d $INC_PATH ]]; then
|
||||
fi
|
||||
export INC_DIR="inc"
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
if [[ ! -d $BIN_PATH ]]; then
|
||||
echo "$0: ERROR: bin is not a directory under topdir: $BIN_PATH" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
@@ -372,6 +374,34 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
if [[ ! -d $BIN_PATH ]]; then
|
||||
echo "$0: ERROR: bin is not a directory under topdir: $BIN_PATH" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
|
||||
# verify we have our awk script
|
||||
#
|
||||
export YEAR_NAVBAR_AWK="$BIN_DIR/subst.year-navbar.awk"
|
||||
if [[ ! -e $YEAR_NAVBAR_AWK ]]; then
|
||||
echo "$0: ERROR: bin/subst.year-navbar.awk does not exist: $YEAR_NAVBAR_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $YEAR_NAVBAR_AWK ]]; then
|
||||
echo "$0: ERROR: bin/subst.year-navbar.awk is not a file: $YEAR_NAVBAR_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -r $YEAR_NAVBAR_AWK ]]; then
|
||||
echo "$0: ERROR: bin/subst.year-navbar.awk is not a readable file: $YEAR_NAVBAR_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that YEAR_ARG is a entry directory
|
||||
#
|
||||
if [[ ! -d $YEAR_ARG ]]; then
|
||||
@@ -388,6 +418,7 @@ if [[ -z $YEAR_DIR ]]; then
|
||||
exit 3
|
||||
fi
|
||||
|
||||
|
||||
# verify we have a non-empty readable .top file
|
||||
#
|
||||
export TOP_FILE=".top"
|
||||
@@ -408,21 +439,6 @@ if [[ ! -s $TOP_FILE ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify we have our awk script
|
||||
#
|
||||
export YEAR_NAVBAR_AWK="$BIN_DIR/subst.year-navbar.awk"
|
||||
if [[ ! -e $YEAR_NAVBAR_AWK ]]; then
|
||||
echo "$0: ERROR: bin/subst.year-navbar.awk does not exist: $YEAR_NAVBAR_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $YEAR_NAVBAR_AWK ]]; then
|
||||
echo "$0: ERROR: bin/subst.year-navbar.awk is not a file: $YEAR_NAVBAR_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -r $YEAR_NAVBAR_AWK ]]; then
|
||||
echo "$0: ERROR: bin/subst.year-navbar.awk is not a readable file: $YEAR_NAVBAR_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# determine The N-th IOCCC string
|
||||
#
|
||||
@@ -445,6 +461,7 @@ if [[ -z $ORDINAL ]]; then
|
||||
exit 211
|
||||
fi
|
||||
|
||||
|
||||
# parameter debugging
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -475,6 +492,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: ORDINAL=$ORDINAL" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# If -N, time to exit
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -484,26 +502,31 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# output TITLE substitution
|
||||
#
|
||||
echo "-s"
|
||||
echo "TITLE=$YEAR_DIR - The $ORDINAL IOCCC"
|
||||
|
||||
|
||||
# output DESCRIPTION substitution
|
||||
#
|
||||
echo "-s"
|
||||
echo "DESCRIPTION=IOCCC Year $YEAR_DIR"
|
||||
|
||||
|
||||
# output KEYWORDS substitution
|
||||
#
|
||||
echo "-s"
|
||||
echo "KEYWORDS=IOCCC, $YEAR_DIR, IOCCC $YEAR_DIR, IOCCC entry, The $ORDINAL IOCCC"
|
||||
|
||||
|
||||
# output HEADER_2 substitution
|
||||
#
|
||||
echo "-s"
|
||||
echo "HEADER_2=$YEAR_DIR - The $ORDINAL IOCCC"
|
||||
|
||||
|
||||
# output navbar left hand side links
|
||||
#
|
||||
awk -v year_arg="$YEAR_DIR" -f "$YEAR_NAVBAR_AWK" "$TOP_FILE"
|
||||
@@ -513,6 +536,7 @@ if [[ $status -ne 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# output navbar right hand side links
|
||||
#
|
||||
echo "-s"
|
||||
@@ -520,6 +544,7 @@ echo "INVENTORY_LINK=#inventory"
|
||||
echo "-s"
|
||||
echo "INVENTORY_TEXT=Inventory"
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
exit 0
|
||||
+52
-26
@@ -26,6 +26,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -69,6 +70,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -81,6 +83,7 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.3.10 2024-08-05"
|
||||
@@ -110,10 +113,11 @@ if [[ -z "$GIT_TOOL" ]]; then
|
||||
exit 8
|
||||
fi
|
||||
|
||||
|
||||
# set usage message
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
[-p tool] [-w site_url] [-W]
|
||||
[-w site_url] [-W]
|
||||
YYYY/dir
|
||||
|
||||
-h print help message and exit
|
||||
@@ -126,8 +130,6 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
-n go thru the actions, but do not update any files (def: do the action)
|
||||
-N do not process file, just parse arguments and ignore the file (def: process the file)
|
||||
|
||||
-p tool This option is ignored
|
||||
|
||||
-w site_url This option is ignored
|
||||
|
||||
-W Warn if a file in the manifest is missing: (def: error if a file is missing)
|
||||
@@ -148,15 +150,17 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# setup
|
||||
#
|
||||
export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
export EXIT_CODE="0"
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNp:U:w:W flag; do
|
||||
while getopts :hv:Vd:D:nNU:w:W flag; do
|
||||
case "$flag" in
|
||||
h) echo "$USAGE" 1>&2
|
||||
exit 2
|
||||
@@ -173,7 +177,6 @@ while getopts :hv:Vd:D:nNp:U:w:W flag; do
|
||||
;;
|
||||
N) DO_NOT_PROCESS="-N"
|
||||
;;
|
||||
p) ;;
|
||||
U) ;;
|
||||
w) ;;
|
||||
W) CAP_W_FLAG_FOUND="true"
|
||||
@@ -195,7 +198,7 @@ while getopts :hv:Vd:D:nNp:U:w:W flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# parse the command line arguments
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -214,6 +217,7 @@ fi
|
||||
#
|
||||
export ENTRY_PATH="$1"
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -234,6 +238,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -257,6 +262,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
@@ -266,6 +272,28 @@ if [[ ! -d $BIN_PATH ]]; then
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
|
||||
# verify we have our awk tool
|
||||
#
|
||||
export FILELIST_ENTRY_JSON_AWK="$BIN_DIR/filelist.entry.json.awk"
|
||||
if [[ ! -e $FILELIST_ENTRY_JSON_AWK ]]; then
|
||||
echo "$0: ERROR: filelist.entry.json.awk does not exist: $FILELIST_ENTRY_JSON_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $FILELIST_ENTRY_JSON_AWK ]]; then
|
||||
echo "$0: ERROR: filelist.entry.json.awk is not a file: $FILELIST_ENTRY_JSON_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -r $FILELIST_ENTRY_JSON_AWK ]]; then
|
||||
echo "$0: ERROR: filelist.entry.json.awk is not a readable file: $FILELIST_ENTRY_JSON_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -s $FILELIST_ENTRY_JSON_AWK ]]; then
|
||||
echo "$0: ERROR: filelist.entry.json.awk is not a not a non-empty readable file: $FILELIST_ENTRY_JSON_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify that ENTRY_PATH is a entry directory
|
||||
#
|
||||
if [[ ! -d $ENTRY_PATH ]]; then
|
||||
@@ -339,25 +367,6 @@ if [[ ! -r $ENTRY_JSON ]]; then
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# verify we have our awk tool
|
||||
#
|
||||
export FILELIST_ENTRY_JSON_AWK="$BIN_DIR/filelist.entry.json.awk"
|
||||
if [[ ! -e $FILELIST_ENTRY_JSON_AWK ]]; then
|
||||
echo "$0: ERROR: filelist.entry.json.awk does not exist: $FILELIST_ENTRY_JSON_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $FILELIST_ENTRY_JSON_AWK ]]; then
|
||||
echo "$0: ERROR: filelist.entry.json.awk is not a file: $FILELIST_ENTRY_JSON_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -r $FILELIST_ENTRY_JSON_AWK ]]; then
|
||||
echo "$0: ERROR: filelist.entry.json.awk is not a readable file: $FILELIST_ENTRY_JSON_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -s $FILELIST_ENTRY_JSON_AWK ]]; then
|
||||
echo "$0: ERROR: filelist.entry.json.awk is not a not a non-empty readable file: $FILELIST_ENTRY_JSON_AWK" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# verify we have non-empty readable ioccc.css file
|
||||
#
|
||||
@@ -379,6 +388,7 @@ if [[ ! -s $IOCCC_CSS ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# verify we have non-empty readable var.mk file
|
||||
#
|
||||
export VAR_MK="var.mk"
|
||||
@@ -399,6 +409,7 @@ if [[ ! -s $VAR_MK ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# verify we have non-empty readable 1337.mk
|
||||
#
|
||||
export LEET_MK="1337.mk"
|
||||
@@ -419,6 +430,7 @@ if [[ ! -s $LEET_MK ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# determine the name of our tarball
|
||||
#
|
||||
# TARBALL - the same of the compressed tarball to verify and if needed re-build
|
||||
@@ -427,6 +439,7 @@ fi
|
||||
export TARBALL="$YYYY_DIR/$ENTRY_ID.tar.bz2"
|
||||
export REBUILD_TARBALL=
|
||||
|
||||
|
||||
# parameter debugging
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -447,6 +460,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: CD_FAILED=$CD_FAILED" 1>&2
|
||||
echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2
|
||||
echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2
|
||||
echo "$0: debug[3]: FILELIST_ENTRY_JSON_AWK=$FILELIST_ENTRY_JSON_AWK" 1>&2
|
||||
echo "$0: debug[3]: YEAR_DIR=$YEAR_DIR" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_DIR=$ENTRY_DIR" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_ID=$ENTRY_ID" 1>&2
|
||||
@@ -455,7 +469,6 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: DOT_PATH=$DOT_PATH" 1>&2
|
||||
echo "$0: debug[3]: DOT_PATH_CONTENT=$DOT_PATH_CONTENT" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_JSON=$ENTRY_JSON" 1>&2
|
||||
echo "$0: debug[3]: FILELIST_ENTRY_JSON_AWK=$FILELIST_ENTRY_JSON_AWK" 1>&2
|
||||
echo "$0: debug[3]: IOCCC_CSS=$IOCCC_CSS" 1>&2
|
||||
echo "$0: debug[3]: VAR_MK=$VAR_MK" 1>&2
|
||||
echo "$0: debug[3]: LEET_MK=$LEET_MK" 1>&2
|
||||
@@ -463,6 +476,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: REBUILD_TARBALL=$REBUILD_TARBALL" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# If -N, time to exit
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -472,6 +486,7 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# test - if needed - if the tarball is a non-empty writable file
|
||||
#
|
||||
if [[ -z $REBUILD_TARBALL && ! -e $TARBALL ]]; then
|
||||
@@ -503,6 +518,7 @@ if [[ -z $REBUILD_TARBALL && ! -s $TARBALL ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary file manifest list
|
||||
#
|
||||
export TMP_MANIFEST_LIST=".tmp.$NAME.MANIFEST_LIST.$$.tmp"
|
||||
@@ -525,6 +541,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary file manifest list is not used: $TMP_MANIFEST_LIST" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary sort list of files to tar
|
||||
#
|
||||
export TMP_FILES_TO_TAR=".tmp.$NAME.FILES_TO_TAR.$$.tmp"
|
||||
@@ -547,6 +564,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary list of files to tar is not used: $TMP_FILES_TO_TAR" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary exit code
|
||||
#
|
||||
# It is a pain to set the EXIT_CODE deep inside a loop, so we write the EXIT_CODE into a file
|
||||
@@ -572,6 +590,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary exit code is not used: $TMP_EXIT_CODE" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# generate sorted list of entry files from the entry's manifest
|
||||
#
|
||||
# We also add ioccc.css and var.mk from the top level.
|
||||
@@ -598,6 +617,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary file manifest list was not formed: $TMP_MANIFEST_LIST" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# generate sorted list of found entry files
|
||||
#
|
||||
# We exclude the compressed tarball itself because we are writing it.
|
||||
@@ -638,6 +658,7 @@ if [[ -z $EXIT_CODE ]]; then
|
||||
exit 16
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary list of files found in the tarball
|
||||
#
|
||||
export TMP_TARBALL_LIST=".tmp.$NAME.TARBALL_LIST.$$.tmp"
|
||||
@@ -660,6 +681,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary of files in the tarball: $TARBALL is not used: $TMP_TARBALL_LIST" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary tarball
|
||||
#
|
||||
export TMP_TARBALL=".tmp.$NAME.TARBALL.$$.tmp"
|
||||
@@ -682,6 +704,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary tarball is not used: $TMP_TARBALL" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# test - if needed - if the sorted list of files from the tarball matches the sorted list of found entry files
|
||||
#
|
||||
if [[ -z $REBUILD_TARBALL ]]; then
|
||||
@@ -722,6 +745,7 @@ if [[ -z $REBUILD_TARBALL ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# test - if needed - if the files in the tarball match the contents of the entry's files
|
||||
#
|
||||
if [[ -z $REBUILD_TARBALL ]]; then
|
||||
@@ -746,6 +770,7 @@ if [[ -z $REBUILD_TARBALL ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# test - if needed - update the tarball
|
||||
#
|
||||
# We use gnu tar to form the bzip2 compressed tarball with careful arguments
|
||||
@@ -865,6 +890,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[1]: no need to update $TARBALL" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
|
||||
+32
-5
@@ -26,6 +26,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -69,6 +70,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -81,6 +83,7 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
|
||||
export VERSION="1.2.8 2024-08-05"
|
||||
@@ -110,10 +113,11 @@ if [[ -z "$GIT_TOOL" ]]; then
|
||||
exit 8
|
||||
fi
|
||||
|
||||
|
||||
# set usage message
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
[-p tool] [-w site_url] [-W]
|
||||
[-w site_url] [-W]
|
||||
YYYY
|
||||
|
||||
-h print help message and exit
|
||||
@@ -126,8 +130,6 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
-n go thru the actions, but do not update any files (def: do the action)
|
||||
-N do not process file, just parse arguments and ignore the file (def: process the file)
|
||||
|
||||
-p tool This option is ignored
|
||||
|
||||
-w site_url This option is ignored
|
||||
|
||||
-W Warn if a file in the manifest is missing: (def: error if a file is missing)
|
||||
@@ -148,15 +150,17 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# setup
|
||||
#
|
||||
export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
export EXIT_CODE="0"
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNp:U:w:W flag; do
|
||||
while getopts :hv:Vd:D:nNU:w:W flag; do
|
||||
case "$flag" in
|
||||
h) echo "$USAGE" 1>&2
|
||||
exit 2
|
||||
@@ -173,7 +177,6 @@ while getopts :hv:Vd:D:nNp:U:w:W flag; do
|
||||
;;
|
||||
N) DO_NOT_PROCESS="-N"
|
||||
;;
|
||||
p) ;;
|
||||
U) ;;
|
||||
w) ;;
|
||||
W) CAP_W_FLAG_FOUND="true"
|
||||
@@ -196,6 +199,7 @@ while getopts :hv:Vd:D:nNp:U:w:W flag; do
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
# parse the command line arguments
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -214,6 +218,7 @@ fi
|
||||
#
|
||||
export YYYY="$1"
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -234,6 +239,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -257,6 +263,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that we have a bin subdirectory
|
||||
#
|
||||
export BIN_PATH="$TOPDIR/bin"
|
||||
@@ -266,6 +273,7 @@ if [[ ! -d $BIN_PATH ]]; then
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
|
||||
# verify we have our awk tool
|
||||
#
|
||||
export FILELIST_ENTRY_JSON_AWK="$BIN_DIR/filelist.entry.json.awk"
|
||||
@@ -286,6 +294,7 @@ if [[ ! -s $FILELIST_ENTRY_JSON_AWK ]]; then
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
||||
# verify we have non-empty readable ioccc.css file
|
||||
#
|
||||
export IOCCC_CSS="ioccc.css"
|
||||
@@ -306,6 +315,7 @@ if [[ ! -s $IOCCC_CSS ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# verify we have non-empty readable ioccc.css file
|
||||
#
|
||||
export VAR_MK="var.mk"
|
||||
@@ -326,6 +336,7 @@ if [[ ! -s $VAR_MK ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# verify we have non-empty readable 1337.mk
|
||||
#
|
||||
export LEET_MK="1337.mk"
|
||||
@@ -346,6 +357,7 @@ if [[ ! -s $LEET_MK ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# verify we have non-empty readable year level .filelist file
|
||||
#
|
||||
export FILELIST="$YYYY/.filelist"
|
||||
@@ -366,6 +378,7 @@ if [[ ! -s $FILELIST ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# determine the name of our tarball
|
||||
#
|
||||
# TARBALL - the same of the compressed tarball to verify and if needed re-build
|
||||
@@ -374,6 +387,7 @@ fi
|
||||
export TARBALL="$YYYY/$YYYY.tar.bz2"
|
||||
export REBUILD_TARBALL=
|
||||
|
||||
|
||||
# parameter debugging
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -404,6 +418,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: REBUILD_TARBALL=$REBUILD_TARBALL" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# If -N, time to exit
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -413,6 +428,7 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# test - if needed - if the tarball is a non-empty writable file
|
||||
#
|
||||
if [[ -z $REBUILD_TARBALL && ! -e $TARBALL ]]; then
|
||||
@@ -444,6 +460,7 @@ if [[ -z $REBUILD_TARBALL && ! -s $TARBALL ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary file manifest list
|
||||
#
|
||||
export TMP_MANIFEST_LIST=".tmp.$NAME.MANIFEST_LIST.$$.tmp"
|
||||
@@ -466,6 +483,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary file manifest list is not used: $TMP_MANIFEST_LIST" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary sort list of files to tar
|
||||
#
|
||||
export TMP_FILES_TO_TAR=".tmp.$NAME.FILES_TO_TAR.$$.tmp"
|
||||
@@ -488,6 +506,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary list of files to tar is not used: $TMP_FILES_TO_TAR" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary exit code
|
||||
#
|
||||
# It is a pain to set the EXIT_CODE deep inside a loop, so we write the EXIT_CODE into a file
|
||||
@@ -513,6 +532,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary exit code is not used: $TMP_EXIT_CODE" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# generate sorted list of entry files from the IOCCC years manifest
|
||||
#
|
||||
# We also add ioccc.css and var.mk from the top level.
|
||||
@@ -701,6 +721,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary file manifest list was not formed: $TMP_MANIFEST_LIST" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# generate sorted list of found entry files
|
||||
#
|
||||
# We exclude the compressed tarball itself because we are writing it.
|
||||
@@ -741,6 +762,7 @@ if [[ -z $EXIT_CODE ]]; then
|
||||
exit 16
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary list of files found in the tarball
|
||||
#
|
||||
export TMP_TARBALL_LIST=".tmp.$NAME.TARBALL_LIST.$$.tmp"
|
||||
@@ -763,6 +785,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary of files in the tarball: $TARBALL is not used: $TMP_TARBALL_LIST" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# create a temporary tarball
|
||||
#
|
||||
export TMP_TARBALL=".tmp.$NAME.TARBALL.$$.tmp"
|
||||
@@ -785,6 +808,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary tarball is not used: $TMP_TARBALL" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# test - if needed - if the sorted list of files from the tarball matches the sorted list of found entry files
|
||||
#
|
||||
if [[ -z $REBUILD_TARBALL ]]; then
|
||||
@@ -825,6 +849,7 @@ if [[ -z $REBUILD_TARBALL ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# test - if needed - if the files in the tarball match the contents of the entry's files
|
||||
#
|
||||
if [[ -z $REBUILD_TARBALL ]]; then
|
||||
@@ -849,6 +874,7 @@ if [[ -z $REBUILD_TARBALL ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# test - if needed - update the tarball
|
||||
#
|
||||
# We use gnu tar to form the bzip2 compressed tarball with careful arguments
|
||||
@@ -968,6 +994,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[1]: no need to update $TARBALL" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
|
||||
+18
-6
@@ -26,6 +26,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -69,6 +70,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# setup bash file matching
|
||||
#
|
||||
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
|
||||
@@ -81,6 +83,7 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.0.4 2024-08-05"
|
||||
@@ -110,10 +113,11 @@ if [[ -z "$GIT_TOOL" ]]; then
|
||||
exit 8
|
||||
fi
|
||||
|
||||
|
||||
# set usage message
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
[-p tool] [-w site_url] [-W]
|
||||
[-w site_url] [-W]
|
||||
YYYY/dir
|
||||
|
||||
-h print help message and exit
|
||||
@@ -126,8 +130,6 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
-n go thru the actions, but do not update any files (def: do the action)
|
||||
-N do not process file, just parse arguments and ignore the file (def: process the file)
|
||||
|
||||
-p tool This option is ignored
|
||||
|
||||
-w site_url This option is ignored
|
||||
|
||||
-W Warn if a file in the manifest is missing: (def: error if a file is missing)
|
||||
@@ -148,14 +150,16 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# setup
|
||||
#
|
||||
export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNp:U:w:W flag; do
|
||||
while getopts :hv:Vd:D:nNU:w:W flag; do
|
||||
case "$flag" in
|
||||
h) echo "$USAGE" 1>&2
|
||||
exit 2
|
||||
@@ -172,7 +176,6 @@ while getopts :hv:Vd:D:nNp:U:w:W flag; do
|
||||
;;
|
||||
N) DO_NOT_PROCESS="-N"
|
||||
;;
|
||||
p) ;;
|
||||
U) ;;
|
||||
w) ;;
|
||||
W) CAP_W_FLAG_FOUND="true"
|
||||
@@ -194,7 +197,7 @@ while getopts :hv:Vd:D:nNp:U:w:W flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# parse the command line arguments
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -213,6 +216,7 @@ fi
|
||||
#
|
||||
export ENTRY_PATH="$1"
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -233,6 +237,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -256,6 +261,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that ENTRY_PATH is a entry directory
|
||||
#
|
||||
if [[ ! -d $ENTRY_PATH ]]; then
|
||||
@@ -305,6 +311,7 @@ if [[ ! -w $YYYY_DIR ]]; then
|
||||
exit 7
|
||||
fi
|
||||
|
||||
|
||||
# determine the name of our tarball
|
||||
#
|
||||
# TARBALL - the same of the compressed tarball to verify and if needed re-build
|
||||
@@ -331,6 +338,7 @@ if [[ ! -s $TARBALL ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# parameter debugging
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -356,6 +364,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: TARBALL=$TARBALL" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# If -N, time to exit
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -365,6 +374,7 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# untar entry compressed tarball
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -401,6 +411,8 @@ elif [[ $V_FLAG -ge 5 ]]; then
|
||||
"$GTAR_TOOL --totals -jxvf $TARBALL" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
exit 0
|
||||
+17
-6
@@ -26,6 +26,7 @@
|
||||
#
|
||||
# Share and enjoy! :-)
|
||||
|
||||
|
||||
# firewall - run only with a bash that is version 5.1.8 or later
|
||||
#
|
||||
# The "/usr/bin/env bash" command must result in using a bash that
|
||||
@@ -81,6 +82,7 @@ shopt -u nocaseglob # disable strict case matching
|
||||
shopt -u extglob # enable extended globbing patterns
|
||||
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
|
||||
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.0.4 2024-08-05"
|
||||
@@ -110,10 +112,11 @@ if [[ -z "$GIT_TOOL" ]]; then
|
||||
exit 8
|
||||
fi
|
||||
|
||||
|
||||
# set usage message
|
||||
#
|
||||
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
[-p tool] [-w site_url] [-W]
|
||||
[-w site_url] [-W]
|
||||
YYYY
|
||||
|
||||
-h print help message and exit
|
||||
@@ -126,8 +129,6 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
-n go thru the actions, but do not update any files (def: do the action)
|
||||
-N do not process file, just parse arguments and ignore the file (def: process the file)
|
||||
|
||||
-p tool This option is ignored
|
||||
|
||||
-w site_url This option is ignored
|
||||
|
||||
-W Warn if a file in the manifest is missing: (def: error if a file is missing)
|
||||
@@ -148,14 +149,16 @@ Exit codes:
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
# setup
|
||||
#
|
||||
export NOOP=
|
||||
export DO_NOT_PROCESS=
|
||||
|
||||
|
||||
# parse command line
|
||||
#
|
||||
while getopts :hv:Vd:D:nNp:U:w:W flag; do
|
||||
while getopts :hv:Vd:D:nNU:w:W flag; do
|
||||
case "$flag" in
|
||||
h) echo "$USAGE" 1>&2
|
||||
exit 2
|
||||
@@ -172,7 +175,6 @@ while getopts :hv:Vd:D:nNp:U:w:W flag; do
|
||||
;;
|
||||
N) DO_NOT_PROCESS="-N"
|
||||
;;
|
||||
p) ;;
|
||||
U) ;;
|
||||
w) ;;
|
||||
W) CAP_W_FLAG_FOUND="true"
|
||||
@@ -194,7 +196,7 @@ while getopts :hv:Vd:D:nNp:U:w:W flag; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# parse the command line arguments
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -213,6 +215,7 @@ fi
|
||||
#
|
||||
export YYYY="$1"
|
||||
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_TOP_URL")
|
||||
@@ -233,6 +236,7 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -256,6 +260,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# verify that YYYY is an IOCCC year directory
|
||||
#
|
||||
if [[ ! -e $YYYY ]]; then
|
||||
@@ -271,6 +276,7 @@ if [[ ! -r $YYYY ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# verify that YYYY has a non-empty readable .year file
|
||||
#
|
||||
export DOT_YEAR="$YYYY/.year"
|
||||
@@ -291,6 +297,7 @@ if [[ ! -s $DOT_YEAR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
|
||||
# determine the name of our tarball
|
||||
#
|
||||
# TARBALL - the same of the compressed tarball to verify and if needed re-build
|
||||
@@ -317,6 +324,7 @@ if [[ ! -s $TARBALL ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# parameter debugging
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -338,6 +346,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: TARBALL=$TARBALL" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# If -N, time to exit
|
||||
#
|
||||
if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
@@ -347,6 +356,7 @@ if [[ -n $DO_NOT_PROCESS ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# untar entry compressed tarball
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
@@ -383,6 +393,7 @@ elif [[ $V_FLAG -ge 5 ]]; then
|
||||
"$GTAR_TOOL --totals -jxvf $TARBALL" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# All Done!!! All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
exit 0
|
||||
Reference in new issue
Block a user