improve bin tool script shell variable use
We export shell variables where needed. We print debug messages of shell variables in the order they were exported or declared, except for the USAGE shell variable, for those shell variables that were exported or declared prior to the set of debug messages of shell variables. Changed `bin/chk-entry.sh` VERSION from "1.1.3 2024-03-18" to "1.1.4 2024-03-26". Changed `bin/gen-authors.sh` VERSION from "1.3.1 2024-03-18" to "1.3.2 2024-03-26". Changed `bin/gen-location.sh` VERSION from "1.1.1 2024-03-18" to "1.1.2 2024-03-26". Changed `bin/gen-other-html.sh` VERSION from "1.0.1 2024-03-08" to "1.0.2 2024-03-26". Changed `bin/gen-sitemap.sh` VERSION from "1.3.2 2024-03-18" to "1.3.3 2024-03-26". Changed `bin/gen-status.sh` VERSION from "1.1.1 2024-03-18" to "1.1.2 2024-03-26". Changed `bin/gen-years.sh` VERSION from "1.0.2 2024-03-13" to "1.0.3 2024-03-26". Changed `bin/md2html.sh` VERSION from "1.1.1 2024-03-09" to "1.1.2 2024-03-26". Changed `bin/output-index-author.sh` VERSION from "1.5.1 2024-03-19" to "1.5.2 2024-03-26". Changed `bin/output-index-inventory.sh` VERSION from "1.2.2 2024-03-19" to "1.2.3 2024-03-26". Changed `bin/output-year-index.sh` VERSION from "1.1.1 2024-03-19" to "1.1.2 2024-03-26". Changed `bin/pandoc-wrapper.sh` VERSION from "1.5.2 2024-03-19" to "1.5.3 2024-03-26". Changed `bin/quick-readme2index.sh` VERSION from "1.1.2 2024-03-08" to "1.1.3 2024-03-26". Changed `bin/readme2index.sh` VERSION from "1.2.1 2024-02-23" to "1.2.2 2024-02-26". Changed `bin/sort.gitignore.sh` VERSION from "1.1.2 2024-03-18" to "1.1.3 2024-03-26". Changed `bin/status2html.sh` VERSION from "1.1.1 2024-03-19" to "1.1.2 2024-03-26". Changed `bin/subst.default.sh` VERSION from "1.2.1 2024-02-23" to "1.2.2 2024-02-26". Changed `bin/subst.entry-index.sh` VERSION from "1.3.1 2024-03-19" to "1.3.2 2024-03-26". Changed `bin/tar-all.sh` VERSION from "1.1.1 2024-03-18" to "1.1.2 2024-03-26". Changed `bin/tar-entry.sh` VERSION from "1.3.1 2024-03-25" to "1.3.2 2024-03-26". Changed `bin/tar-year.sh` VERSION from "1.1.1 2024-03-18" to "1.1.2 2024-03-26". Changed `bin/all-years.sh` VERSION from "1.0.1 2024-02-23" to "1.0.2 2024-02-26". Changed `bin/gen-top-html.sh` VERSION from "1.2.1 2024-03-08" to "1.2.2 2024-03-26". Changed `bin/gen-year-index.sh` VERSION from "1.0.3 2024-03-09" to "1.0.4 2024-03-26". Changed `bin/subst.year-index.sh` VERSION from "1.1.1 2024-03-19" to "1.1.2 2024-03-26". Changed `bin/untar-entry.sh` VERSION from "1.0 2024-03-25" to "1.0.1 2024-03-26".
This commit is contained in:
1 parent
0834d59263
commit
c176b51cec
27 files changed
+285
-178
No files matched your search
+11
-10
@@ -108,7 +108,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.1.1 2024-03-19"
|
||||
export VERSION="1.1.2 2024-03-26"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -189,7 +189,8 @@ $NAME version: $VERSION"
|
||||
#
|
||||
function output_award
|
||||
{
|
||||
local ENTRY_JSON_PATH; # the .entry.json path
|
||||
local ENTRY_JSON_PATH; # the .entry.json path
|
||||
local AWARD_STRING; # winning entry award string
|
||||
|
||||
# parse args
|
||||
#
|
||||
@@ -213,12 +214,12 @@ function output_award
|
||||
|
||||
# obtain the award string
|
||||
#
|
||||
AWARD=$(grep -F '"award" : "' "$ENTRY_JSON_PATH" | sed -e 's/^.*"award" : "//' -e 's/",//')
|
||||
if [[ -z $AWARD ]]; then
|
||||
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"
|
||||
echo "$AWARD_STRING"
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -364,9 +365,6 @@ if [[ $# -ne 1 ]]; then
|
||||
fi
|
||||
#
|
||||
export YYYY="$1"
|
||||
if [[ $V_FLAG -ge 1 ]]; then
|
||||
echo "$0: debug[1]: YYYY=$YYYY" 1>&2
|
||||
fi
|
||||
if [[ -z $YYYY ]]; then
|
||||
echo "$0: ERROR: YYYY arg is empty" 1>&2
|
||||
exit 3
|
||||
@@ -484,6 +482,7 @@ fi
|
||||
# determine The N-th IOCCC string
|
||||
#
|
||||
LINE_NUM=$(sed -n "/$YYYY/=" "$TOP_FILE" | head -1)
|
||||
export LINE_NUM
|
||||
if [[ -z $LINE_NUM ]]; then
|
||||
echo "$0: ERROR: cannot determine line number in $TOP_FILE for year: $YYYY" 1>&2
|
||||
exit 10
|
||||
@@ -505,12 +504,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]: REPO_URL=$REPO_URL" 1>&2
|
||||
echo "$0: debug[3]: URL=$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]: 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]: TOP_FILE=$TOP_FILE" 1>&2
|
||||
echo "$0: debug[3]: YEAR_FILE=$YEAR_FILE" 1>&2
|
||||
echo "$0: debug[3]: LINE_NUM=$LINE_NUM" 1>&2
|
||||
@@ -528,7 +527,7 @@ fi
|
||||
|
||||
# create a temporary markdown for pandoc to process
|
||||
#
|
||||
TMP_FILE=".$NAME.$$.md"
|
||||
export TMP_FILE=".$NAME.$$.md"
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: temporary markdown file: $TMP_FILE" 1>&2
|
||||
fi
|
||||
@@ -612,6 +611,7 @@ for YYYY_DIR in $(< "$YEAR_FILE"); do
|
||||
exit 7
|
||||
fi
|
||||
DOT_PATH_CONTENT=$(< "$DOT_PATH")
|
||||
export DOT_PATH_CONTENT
|
||||
if [[ $YYYY_DIR != "$DOT_PATH_CONTENT" ]]; then
|
||||
echo "$0: ERROR: arg: $YYYY_DIR does not match $DOT_PATH contents: $DOT_PATH_CONTENT" 1>&2
|
||||
exit 7
|
||||
@@ -633,6 +633,7 @@ for YYYY_DIR in $(< "$YEAR_FILE"); do
|
||||
# determine the award for this entry
|
||||
#
|
||||
AWARD=$(output_award "$ENTRY_JSON")
|
||||
export AWARD
|
||||
if [[ -z $AWARD ]]; then
|
||||
echo "$0: ERROR: cannot find award in .entry.json: $ENTRY_JSON" 1>&2
|
||||
exit 7
|
||||
|
||||
Reference in new issue
Block a user