improve exit code use in bin scripts
The use of exit codes and exit code ranges has been made more consistent across most bin tools.
This commit is contained in:
1 parent
de0619a8b6
commit
09b8de5081
21 files changed
+1071
-1164
No files matched your search
+27
-29
@@ -78,7 +78,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.3 2024-02-11"
|
||||
export VERSION="1.3.1 2024-02-23"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -86,7 +86,7 @@ GIT_TOOL=$(type -P git)
|
||||
export GIT_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: git tool is not installed or not in \$PATH" 1>&2
|
||||
exit 10
|
||||
exit 5
|
||||
fi
|
||||
"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
status="$?"
|
||||
@@ -150,16 +150,14 @@ NOTE: Any '-D docroot/', '-t tagline', '-T md2html.sh', '-p tool', '-u repo_url'
|
||||
|
||||
Exit codes:
|
||||
0 all OK
|
||||
1 some tool exited non-zero
|
||||
1 some internal tool exited non-zero
|
||||
2 -h and help string printed or -V and version string printed
|
||||
3 command line error
|
||||
4 bash version is < 4.2
|
||||
5 tool and/or md2html.sh is not an executable file
|
||||
6 problems found with or in the topdir directory
|
||||
7 problems found with or in the topdir/YYYY directory
|
||||
8 problems found with or in the topdir/YYYY/dir directory
|
||||
>= 10 < 200 internal error
|
||||
>= 200 ((not used))
|
||||
5 some internal tool is not found or not an executable file
|
||||
6 problems found with or in the topdir or topdir/YYYY directory
|
||||
7 problems found with or in the entry topdir/YYYY/dir directory
|
||||
>= 10 internal error
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
@@ -419,19 +417,19 @@ for YYYY in $(< "$TOP_FILE"); do
|
||||
#
|
||||
if [[ ! -e $YYYY ]]; then
|
||||
echo "$0: ERROR: YYYY does not exist: $YYYY" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -d $YYYY ]]; then
|
||||
echo "$0: ERROR: YYYY is not a directory: $YYYY" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -r $YYYY ]]; then
|
||||
echo "$0: ERROR: YYYY is not an readable directory: $YYYY" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
@@ -441,25 +439,25 @@ for YYYY in $(< "$TOP_FILE"); do
|
||||
export YEAR_FILE="$YYYY/.year"
|
||||
if [[ ! -e $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year does not exist: $YEAR_FILE" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -f $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year is not a regular file: $YEAR_FILE" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -r $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year is not an readable file: $YEAR_FILE" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -s $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year is not a non-empty readable file: $YEAR_FILE" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
@@ -479,33 +477,33 @@ for YYYY in $(< "$TOP_FILE"); do
|
||||
#
|
||||
if [[ ! -d $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR is not a directory: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -w $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR is not a writable directory: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
export YEAR_DIR=${YYYY_DIR%%/*}
|
||||
if [[ -z $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR not in YYYY/dir form: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
export ENTRY_DIR=${YYYY_DIR#*/}
|
||||
if [[ -z $ENTRY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR not in $YEAR_DIR/dir form: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ $ENTRY_DIR = */* ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR: $YYYY_DIR dir contains a /: $ENTRY_DIR" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
@@ -514,19 +512,19 @@ for YYYY in $(< "$TOP_FILE"); do
|
||||
#
|
||||
if [[ ! -e $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR does not exist: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE="7" # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -d $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR is not a directory: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE="7" # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -w $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR is not an writable directory: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE="7" # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
@@ -536,33 +534,33 @@ for YYYY in $(< "$TOP_FILE"); do
|
||||
export DOT_PATH="$YYYY_DIR/.path"
|
||||
if [[ ! -s $DOT_PATH ]]; then
|
||||
echo "$0: ERROR: not a non-empty file: $DOT_PATH" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE="7" # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
DOT_PATH_CONTENT=$(< "$DOT_PATH")
|
||||
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_CODE="8" # exit 8
|
||||
EXIT_CODE="7" # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
export ENTRY_JSON="$YYYY_DIR/.entry.json"
|
||||
if [[ ! -e $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json does not exist: $ENTRY_JSON" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE="7" # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -f $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a file: $ENTRY_JSON" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE="7" # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -r $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a readable file: $ENTRY_JSON" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE="7" # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
|
||||
+14
-16
@@ -77,7 +77,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.0 2024-02-12"
|
||||
export VERSION="1.0.1 2024-02-23"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -85,7 +85,7 @@ GIT_TOOL=$(type -P git)
|
||||
export GIT_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: git tool is not installed or not in \$PATH" 1>&2
|
||||
exit 10
|
||||
exit 5
|
||||
fi
|
||||
"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
status="$?"
|
||||
@@ -150,16 +150,14 @@ NOTE: Any '-t tagline', '-T md2html.sh', '-p tool', '-u repo_url', '-w site_url'
|
||||
|
||||
Exit codes:
|
||||
0 all OK
|
||||
1 some tool exited non-zero
|
||||
1 some internal tool exited non-zero
|
||||
2 -h and help string printed or -V and version string printed
|
||||
3 command line error
|
||||
4 bash version is < 4.2
|
||||
5 tool and/or md2html.sh is not an executable file
|
||||
6 problems found with or in the topdir directory
|
||||
7 problems found with or in the topdir/YYYY directory
|
||||
8 problems found with or in the topdir/YYYY/dir directory
|
||||
>= 10 < 200 internal error
|
||||
>= 200 ((not used))
|
||||
5 some internal tool is not found or not an executable file
|
||||
6 problems found with or in the topdir or topdir/YYYY directory
|
||||
7 problems found with or in the entry topdir/YYYY/dir directory
|
||||
>= 10 internal error
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
@@ -419,19 +417,19 @@ for YYYY in $(< "$TOP_FILE"); do
|
||||
#
|
||||
if [[ ! -e $YYYY ]]; then
|
||||
echo "$0: ERROR: YYYY does not exist: $YYYY" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -d $YYYY ]]; then
|
||||
echo "$0: ERROR: YYYY is not a directory: $YYYY" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -r $YYYY ]]; then
|
||||
echo "$0: ERROR: YYYY is not an readable directory: $YYYY" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
@@ -441,25 +439,25 @@ for YYYY in $(< "$TOP_FILE"); do
|
||||
export YEAR_FILE="$YYYY/.year"
|
||||
if [[ ! -e $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year does not exist: $YEAR_FILE" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -f $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year is not a regular file: $YEAR_FILE" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -r $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year is not an readable file: $YEAR_FILE" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -s $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year is not a non-empty readable file: $YEAR_FILE" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
|
||||
+49
-60
@@ -49,7 +49,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 2024-02-17"
|
||||
export VERSION="1.1.1 2024-02-23"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -57,7 +57,7 @@ GIT_TOOL=$(type -P git)
|
||||
export GIT_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: git tool is not installed or not in \$PATH" 1>&2
|
||||
exit 210
|
||||
exit 5
|
||||
fi
|
||||
"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
status="$?"
|
||||
@@ -92,16 +92,14 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
|
||||
Exit codes:
|
||||
0 all OK
|
||||
1 entry files to not match manifest in .entry.json
|
||||
1 some internal tool exited non-zero
|
||||
2 -h and help string printed or -V and version string printed
|
||||
3 command line error
|
||||
4 bash version is < 4.2
|
||||
5 YYYY/dir is not a entry directory
|
||||
6 bin/filelist.entry.json.awk is not a non-empty readable file
|
||||
7 error in trying to determine files used by the entry
|
||||
8 missing critical top level file
|
||||
>= 10 < 210 ((not used))
|
||||
>= 210 internal tool error
|
||||
5 some internal tool is not found or not an executable file
|
||||
6 problems found with or in the topdir or topdir/YYYY directory
|
||||
7 problems found with or in the entry topdir/YYYY/dir directory
|
||||
>= 10 internal error
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
@@ -177,37 +175,28 @@ export REPO_NAME
|
||||
if [[ -z $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot find top of git repo directory" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 220
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR does not exist: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 221
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR is not a directory: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 222
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify that we have an 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 223
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to non-existent path: $TOPDIR" 1>&2
|
||||
exit 224
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to a non-directory: $TOPDIR" 1>&2
|
||||
exit 225
|
||||
exit 6
|
||||
fi
|
||||
export CD_FAILED
|
||||
if [[ $V_FLAG -ge 5 ]]; then
|
||||
@@ -216,91 +205,91 @@ fi
|
||||
cd "$TOPDIR" || CD_FAILED="true"
|
||||
if [[ -n $CD_FAILED ]]; then
|
||||
echo "$0: ERROR: cd $TOPDIR failed" 1>&2
|
||||
exit 226
|
||||
exit 6
|
||||
fi
|
||||
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
|
||||
# verify that we have an bin subdirectory
|
||||
#
|
||||
# ENTRY_PATH must be in YYYY/dir form
|
||||
# YYYY must be a directory
|
||||
# YYYY must be a writable directory
|
||||
# YYYY/.year must be a non-empty file
|
||||
# YYYY/dir must be a directory
|
||||
# YYYY/dir/.path must be a non-empty file
|
||||
# ENTRY_PATH must match the contents of YYYY/dir/.path
|
||||
# YYYY/dir/.entry.json must be a non-empty file
|
||||
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
|
||||
#
|
||||
if [[ ! -d $ENTRY_PATH ]]; then
|
||||
echo "$0: ERROR: arg is not a directory: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -w $ENTRY_PATH ]]; then
|
||||
echo "$0: ERROR: arg is not a writable directory: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
export YEAR_DIR=${ENTRY_PATH%%/*}
|
||||
if [[ -z $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: arg not in YYYY/dir form: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
export ENTRY_DIR=${ENTRY_PATH#*/}
|
||||
if [[ -z $ENTRY_DIR ]]; then
|
||||
echo "$0: ERROR: arg: $ENTRY_PATH not in $YEAR_DIR/dir form: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
if [[ $ENTRY_DIR = */* ]]; then
|
||||
echo "$0: ERROR: dir from arg: $ENTRY_PATH contains a /: $ENTRY_DIR" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -d $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY from arg: $ENTRY_PATH is not a directory: $YEAR_DIR" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
export ENTRY_ID="${YEAR_DIR}_${ENTRY_DIR}"
|
||||
export DOT_YEAR="$YEAR_DIR/.year"
|
||||
if [[ ! -s $DOT_YEAR ]]; then
|
||||
echo "$0: ERROR: not a non-empty file: $DOT_YEAR" 1>&2
|
||||
exit 5
|
||||
exit 6
|
||||
fi
|
||||
# Now that we have moved to topdir, form and verify YYYY_DIR is a writable directory
|
||||
export YYYY_DIR="$YEAR_DIR/$ENTRY_DIR"
|
||||
if [[ ! -e $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY/dir from arg: $ENTRY_PATH does not exist: $YYYY_DIR" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -d $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY/dir from arg: $ENTRY_PATH is not a directory: $YYYY_DIR" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -w $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY/dir from arg: $ENTRY_PATH is not a writable directory: $YYYY_DIR" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
export DOT_PATH="$YYYY_DIR/.path"
|
||||
if [[ ! -s $DOT_PATH ]]; then
|
||||
echo "$0: ERROR: not a non-empty file: $DOT_PATH" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
DOT_PATH_CONTENT=$(< "$DOT_PATH")
|
||||
if [[ $ENTRY_PATH != "$DOT_PATH_CONTENT" ]]; then
|
||||
echo "$0: ERROR: arg: $ENTRY_PATH does not match $DOT_PATH contents: $DOT_PATH_CONTENT" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
export ENTRY_JSON="$YYYY_DIR/.entry.json"
|
||||
if [[ ! -e $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json does not exist: $ENTRY_JSON" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -f $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a file: $ENTRY_JSON" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -r $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a readable file: $ENTRY_JSON" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
|
||||
# verify we have our awk tool
|
||||
@@ -308,19 +297,19 @@ fi
|
||||
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 6
|
||||
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 6
|
||||
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 6
|
||||
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 6
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# parameter debugging
|
||||
@@ -368,12 +357,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_MANIFEST_LIST"
|
||||
if [[ -e $TMP_MANIFEST_LIST ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary file manifest list: $TMP_MANIFEST_LIST" 1>&2
|
||||
exit 227
|
||||
exit 10
|
||||
fi
|
||||
:> "$TMP_MANIFEST_LIST"
|
||||
if [[ ! -e $TMP_MANIFEST_LIST ]]; then
|
||||
echo "$0: ERROR: cannot create temporary file manifest list: $TMP_MANIFEST_LIST" 1>&2
|
||||
exit 228
|
||||
exit 11
|
||||
fi
|
||||
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
|
||||
@@ -390,12 +379,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_FILE_LIST"
|
||||
if [[ -e $TMP_FILE_LIST ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary file manifest list: $TMP_FILE_LIST" 1>&2
|
||||
exit 227
|
||||
exit 12
|
||||
fi
|
||||
:> "$TMP_FILE_LIST"
|
||||
if [[ ! -e $TMP_FILE_LIST ]]; then
|
||||
echo "$0: ERROR: cannot create temporary file manifest list: $TMP_FILE_LIST" 1>&2
|
||||
exit 228
|
||||
exit 13
|
||||
fi
|
||||
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
|
||||
@@ -409,13 +398,13 @@ awk -f "$FILELIST_ENTRY_JSON_AWK" "$ENTRY_JSON" > "$TMP_MANIFEST_LIST"
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: awk -f $FILELIST_ENTRY_JSON_AWK $ENTRY_JSON > $TMP_MANIFEST_LIST failed, error: $status" 1>&2
|
||||
exit 7
|
||||
exit 1
|
||||
fi
|
||||
sort -d -u "$TMP_MANIFEST_LIST" -o "$TMP_MANIFEST_LIST"
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: sort -d -u $TMP_MANIFEST_LIST -o $TMP_MANIFEST_LIST failed, error: $status" 1>&2
|
||||
exit 7
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# generate sorted list of found entry files
|
||||
@@ -426,13 +415,13 @@ find "$ENTRY_PATH" -type f -print > "$TMP_FILE_LIST"
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: find $ENTRY_PATH -type f -print > $TMP_FILE_LIST failed, error: $status" 1>&2
|
||||
exit 7
|
||||
exit 1
|
||||
fi
|
||||
sort -d -u "$TMP_FILE_LIST" -o "$TMP_FILE_LIST"
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: sort -d -u $TMP_FILE_LIST -o $TMP_FILE_LIST failed, error: $status" 1>&2
|
||||
exit 7
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# note if the manifest does NOT match the file list
|
||||
|
||||
+43
-45
@@ -49,7 +49,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.0 2024-02-11"
|
||||
export VERSION="1.0.1 2024-02-23"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -57,7 +57,7 @@ GIT_TOOL=$(type -P git)
|
||||
export GIT_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: git tool is not installed or not in \$PATH" 1>&2
|
||||
exit 10
|
||||
exit 5
|
||||
fi
|
||||
"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
status="$?"
|
||||
@@ -150,16 +150,14 @@ NOTE: The '-v level' is passed as initial command line options to the 'markdown
|
||||
|
||||
Exit codes:
|
||||
0 all OK
|
||||
1 md2html.sh exited non-zero
|
||||
1 some internal tool exited non-zero
|
||||
2 -h and help string printed or -V and version string printed
|
||||
3 command line error
|
||||
4 bash version is < 4.2
|
||||
5 md2html.sh and/or location is not an executable file
|
||||
6 problems found with or in the topdir directory
|
||||
7 problems found with or in the topdir/YYYY directory
|
||||
8 problems found with or in the topdir/YYYY/dir directory
|
||||
>= 10 < 200 ((not used))
|
||||
>= 210 internal tool error
|
||||
5 some internal tool is not found or not an executable file
|
||||
6 problems found with or in the topdir or topdir/YYYY directory
|
||||
7 problems found with or in the entry topdir/YYYY/dir directory
|
||||
>= 10 internal error
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
@@ -548,24 +546,6 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify that we have an author subdirectory
|
||||
#
|
||||
export AUTHOR_PATH="$TOPDIR/author"
|
||||
if [[ ! -d $AUTHOR_PATH ]]; then
|
||||
echo "$0: ERROR: author is not a directory under topdir: $AUTHOR_PATH" 1>&2
|
||||
exit 210
|
||||
fi
|
||||
export AUTHOR_DIR="author"
|
||||
|
||||
# verify that we have an 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 211
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -604,6 +584,24 @@ if [[ ! -x $MD2HTML_SH ]]; then
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# verify that we have an author subdirectory
|
||||
#
|
||||
export AUTHOR_PATH="$TOPDIR/author"
|
||||
if [[ ! -d $AUTHOR_PATH ]]; then
|
||||
echo "$0: ERROR: author is not a directory under topdir: $AUTHOR_PATH" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export AUTHOR_DIR="author"
|
||||
|
||||
# verify that we have an 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"
|
||||
|
||||
# find the location tool
|
||||
#
|
||||
LOCATION_TOOL=$(type -P location)
|
||||
@@ -670,12 +668,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_AUTHORS_MD"
|
||||
if [[ -e $TMP_AUTHORS_MD ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary entry markdown file: $TMP_AUTHORS_MD" 1>&2
|
||||
exit 212
|
||||
exit 10
|
||||
fi
|
||||
:> "$TMP_AUTHORS_MD"
|
||||
if [[ ! -e $TMP_AUTHORS_MD ]]; then
|
||||
echo "$0: ERROR: cannot create temporary entry markdown file: $TMP_AUTHORS_MD" 1>&2
|
||||
exit 213
|
||||
exit 11
|
||||
fi
|
||||
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
|
||||
@@ -692,12 +690,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_SORT_WORD"
|
||||
if [[ -e $TMP_SORT_WORD ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary sort word list file: $TMP_SORT_WORD" 1>&2
|
||||
exit 214
|
||||
exit 12
|
||||
fi
|
||||
:> "$TMP_SORT_WORD"
|
||||
if [[ ! -e $TMP_SORT_WORD ]]; then
|
||||
echo "$0: ERROR: cannot create temporary sort word list file: $TMP_SORT_WORD" 1>&2
|
||||
exit 215
|
||||
exit 13
|
||||
fi
|
||||
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
|
||||
@@ -728,7 +726,7 @@ sort -f -d "$TMP_SORT_WORD" -o "$TMP_SORT_WORD"
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: sort -f -d $TMP_SORT_WORD -o $TMP_SORT_WORD failed, error: $status" 1>&2
|
||||
exit 216
|
||||
exit 14
|
||||
fi
|
||||
|
||||
# generate the temporary entry markdown file
|
||||
@@ -801,32 +799,32 @@ EOF
|
||||
#
|
||||
if [[ -z $sort_word ]]; then
|
||||
echo "$0: ERROR: sort_word is empty" 1>&2
|
||||
exit 217
|
||||
exit 15
|
||||
fi
|
||||
FULL_NAME=$(output_full_name "$filename")
|
||||
if [[ -z $FULL_NAME ]]; then
|
||||
echo "$0: ERROR: full name is empty in: $filename" 1>&2
|
||||
exit 218
|
||||
exit 16
|
||||
fi
|
||||
LOCATION_CODE=$(output_location_code "$filename")
|
||||
if [[ -z $LOCATION_CODE ]]; then
|
||||
echo "$0: ERROR: location code is empty in: $filename" 1>&2
|
||||
exit 219
|
||||
exit 17
|
||||
fi
|
||||
LOCATION_NAME=$("$LOCATION_TOOL" "$LOCATION_CODE" 2>/dev/null)
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: cannot determine location name for location ISO 3166 code: $LOCATION_CODE" 1>&2
|
||||
exit 220
|
||||
exit 18
|
||||
fi
|
||||
if [[ -z $LOCATION_NAME ]]; then
|
||||
echo "$0: ERROR: location name for location ISO 3166 code: $LOCATION_CODE is empty: $LOCATION_NAME" 1>&2
|
||||
exit 221
|
||||
exit 19
|
||||
fi
|
||||
AUTHOR_HANDLE=$(output_author_handle "$filename")
|
||||
if [[ -z $AUTHOR_HANDLE ]]; then
|
||||
echo "$0: ERROR: author handle is empty in: $filename" 1>&2
|
||||
exit 222
|
||||
exit 20
|
||||
fi
|
||||
|
||||
# output author information
|
||||
@@ -846,12 +844,12 @@ EOF
|
||||
fi
|
||||
else
|
||||
echo "$0: ERROR: entry_id is not in YYYY_dir formmat: $entry_id" 1>&2
|
||||
exit 223
|
||||
exit 21
|
||||
fi
|
||||
YYYY_DIR=$(echo "$ENTRY_ID" | tr _ /)
|
||||
if [[ ! -d $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY/dir is not a directory" 1>&2
|
||||
exit 224
|
||||
exit 22
|
||||
fi
|
||||
|
||||
# verify that the .entry.json file is a non-empty readable file
|
||||
@@ -859,19 +857,19 @@ EOF
|
||||
ENTRY_JSON="$YYYY_DIR/.entry.json"
|
||||
if [[ ! -e $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json does not exist: $ENTRY_JSON" 1>&2
|
||||
exit 225
|
||||
exit 23
|
||||
fi
|
||||
if [[ ! -f $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a file: $ENTRY_JSON" 1>&2
|
||||
exit 226
|
||||
exit 24
|
||||
fi
|
||||
if [[ ! -r $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a readable file: $ENTRY_JSON" 1>&2
|
||||
exit 227
|
||||
exit 24
|
||||
fi
|
||||
if [[ ! -s $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a non-empty readable file: $ENTRY_JSON" 1>&2
|
||||
exit 228
|
||||
exit 25
|
||||
fi
|
||||
if [[ $V_FLAG -ge 7 ]]; then
|
||||
echo "$0: debug[7]: .entry.json: $ENTRY_JSON" 1>&2
|
||||
@@ -882,7 +880,7 @@ EOF
|
||||
AWARD=$(output_award "$ENTRY_JSON")
|
||||
if [[ -z $AWARD ]]; then
|
||||
echo "$0: ERROR: award not found in .entry.json: $ENTRY_JSON" 1>&2
|
||||
exit 229
|
||||
exit 27
|
||||
fi
|
||||
|
||||
# output the YYYY/dir entry for this author
|
||||
|
||||
+29
-31
@@ -49,7 +49,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.0 2024-02-11"
|
||||
export VERSION="1.0.1 2024-02-23"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -57,7 +57,7 @@ GIT_TOOL=$(type -P git)
|
||||
export GIT_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: git tool is not installed or not in \$PATH" 1>&2
|
||||
exit 10
|
||||
exit 5
|
||||
fi
|
||||
"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
status="$?"
|
||||
@@ -119,16 +119,14 @@ NOTE: The '-v level' is passed as initial command line options to the 'markdown
|
||||
|
||||
Exit codes:
|
||||
0 all OK
|
||||
1 md2html.sh exited non-zero
|
||||
1 some internal tool exited non-zero
|
||||
2 -h and help string printed or -V and version string printed
|
||||
3 command line error
|
||||
4 bash version is < 4.2
|
||||
5 md2html.sh and/or location is not an executable file
|
||||
6 problems found with or in the topdir directory
|
||||
7 problems found with or in the topdir/YYYY directory
|
||||
8 problems found with or in the topdir/YYYY/dir directory
|
||||
>= 10 < 210 ((not used))
|
||||
>= 210 internal tool error
|
||||
5 some internal tool is not found or not an executable file
|
||||
6 problems found with or in the topdir or topdir/YYYY directory
|
||||
7 problems found with or in the entry topdir/YYYY/dir directory
|
||||
>= 10 internal error
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
@@ -276,24 +274,6 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify that we have an author subdirectory
|
||||
#
|
||||
export AUTHOR_PATH="$TOPDIR/author"
|
||||
if [[ ! -d $AUTHOR_PATH ]]; then
|
||||
echo "$0: ERROR: author is not a directory under topdir: $AUTHOR_PATH" 1>&2
|
||||
exit 210
|
||||
fi
|
||||
export AUTHOR_DIR="author"
|
||||
|
||||
# verify that we have an 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 211
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -317,6 +297,24 @@ 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"
|
||||
if [[ ! -d $AUTHOR_PATH ]]; then
|
||||
echo "$0: ERROR: author is not a directory under topdir: $AUTHOR_PATH" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export AUTHOR_DIR="author"
|
||||
|
||||
# verify that we have an 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 md2html tool is executable
|
||||
#
|
||||
if [[ ! -e $MD2HTML_SH ]]; then
|
||||
@@ -399,12 +397,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_LOC_MD"
|
||||
if [[ -e $TMP_LOC_MD ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary location markdown file: $TMP_LOC_MD" 1>&2
|
||||
exit 212
|
||||
exit 10
|
||||
fi
|
||||
:> "$TMP_LOC_MD"
|
||||
if [[ ! -e $TMP_LOC_MD ]]; then
|
||||
echo "$0: ERROR: cannot create temporary location markdown file: $TMP_LOC_MD" 1>&2
|
||||
exit 213
|
||||
exit 11
|
||||
fi
|
||||
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
|
||||
@@ -433,7 +431,7 @@ fi
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: cannot determine location name for location ISO 3166 code: $LOCATION_CODE" 1>&2
|
||||
exit 214
|
||||
exit 12
|
||||
fi
|
||||
|
||||
# found the number of authors at this location
|
||||
@@ -444,7 +442,7 @@ fi
|
||||
sed -e 's/[[:space:]]*//')
|
||||
if [[ -z $AUTHOR_COUNT || $AUTHOR_COUNT -le 0 ]]; then
|
||||
echo "$0: ERROR: author count was zero for location: $LOCATION_CODE" 1>&2
|
||||
exit 215
|
||||
exit 13
|
||||
fi
|
||||
|
||||
# output markdown entry for this location
|
||||
|
||||
+23
-24
@@ -51,7 +51,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.0 2024-02-12"
|
||||
export VERSION="1.0.1 2024-02-23"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -59,7 +59,7 @@ GIT_TOOL=$(type -P git)
|
||||
export GIT_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: git tool is not installed or not in \$PATH" 1>&2
|
||||
exit 210
|
||||
exit 5
|
||||
fi
|
||||
"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
status="$?"
|
||||
@@ -106,15 +106,14 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N]
|
||||
|
||||
Exit codes:
|
||||
0 all OK
|
||||
1 some internal tool exited non-zero
|
||||
2 -h and help string printed or -V and version string printed
|
||||
3 command line error
|
||||
4 bash version is < 4.2
|
||||
5 YYYY is not a year directory
|
||||
6 subst.year-navbar.awk tool or pandoc wrapper not found
|
||||
7 cannot find a non-empty or read .year file
|
||||
8 .year file under year YYYY is not a non-empty readable file
|
||||
>= 10 < 210 ((not used))
|
||||
>= 210 internal tool error
|
||||
5 some internal tool is not found or not an executable file
|
||||
6 problems found with or in the topdir or topdir/YYYY directory
|
||||
7 problems found with or in the entry topdir/YYYY/dir directory
|
||||
>= 10 internal error
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
@@ -244,28 +243,28 @@ export REPO_NAME
|
||||
if [[ -z $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot find top of git repo directory" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 211
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR does not exist: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 212
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR is not a directory: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 213
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to non-existent path: $TOPDIR" 1>&2
|
||||
exit 217
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to a non-directory: $TOPDIR" 1>&2
|
||||
exit 218
|
||||
exit 6
|
||||
fi
|
||||
export CD_FAILED
|
||||
if [[ $V_FLAG -ge 5 ]]; then
|
||||
@@ -274,7 +273,7 @@ fi
|
||||
cd "$TOPDIR" || CD_FAILED="true"
|
||||
if [[ -n $CD_FAILED ]]; then
|
||||
echo "$0: ERROR: cd $TOPDIR failed" 1>&2
|
||||
exit 219
|
||||
exit 6
|
||||
fi
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
@@ -284,11 +283,11 @@ fi
|
||||
#
|
||||
if [[ ! -d $YYYY ]]; then
|
||||
echo "$0: ERROR: arg is not a directory: $YYYY" 1>&2
|
||||
exit 5
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -r $YYYY ]]; then
|
||||
echo "$0: ERROR: arg is not a writable directory: $YYYY" 1>&2
|
||||
exit 5
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify that YYYY has a non-empty readable .year file
|
||||
@@ -296,19 +295,19 @@ fi
|
||||
export YEAR_FILE="$YYYY/.year"
|
||||
if [[ ! -e $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year does not exist: $YEAR_FILE" 1>&2
|
||||
exit 7
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -f $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year is not a regular file: $YEAR_FILE" 1>&2
|
||||
exit 7
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -r $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year is not an readable file: $YEAR_FILE" 1>&2
|
||||
exit 7
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -s $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year is not a non-empty readable file: $YEAR_FILE" 1>&2
|
||||
exit 7
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify that YYYY/README.md is a non-empty readable file
|
||||
@@ -316,19 +315,19 @@ fi
|
||||
export README_FILE="$YYYY/README.md"
|
||||
if [[ ! -e $README_FILE ]]; then
|
||||
echo "$0: ERROR: year $YYYY README.md does not exist: $README_FILE" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -f $README_FILE ]]; then
|
||||
echo "$0: ERROR: year $YYYY README.md is not a file: $README_FILE" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -r $README_FILE ]]; then
|
||||
echo "$0: ERROR: year $YYYY README.md is not a readable file: $README_FILE" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -s $README_FILE ]]; then
|
||||
echo "$0: ERROR: year $YYYY README.md is not a non-empty readable file: $README_FILE" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify that the md2html.sh is executable
|
||||
|
||||
+36
-38
@@ -49,7 +49,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.0 2024-02-11"
|
||||
export VERSION="1.0.1 2024-02-23"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -57,7 +57,7 @@ GIT_TOOL=$(type -P git)
|
||||
export GIT_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: git tool is not installed or not in \$PATH" 1>&2
|
||||
exit 10
|
||||
exit 5
|
||||
fi
|
||||
"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
status="$?"
|
||||
@@ -69,13 +69,13 @@ TAC_TOOL=$(type -P tac)
|
||||
export TAC_TOOL
|
||||
if [[ ! -x $TAC_TOOL ]]; then
|
||||
echo "$0: FATAL: tac executable is not installed or not in \$PATH" 1>&2
|
||||
exit 11
|
||||
exit 5
|
||||
fi
|
||||
FMT_TOOL=$(type -P fmt)
|
||||
export FMT_TOOL
|
||||
if [[ ! -x $FMT_TOOL ]]; then
|
||||
echo "$0: FATAL: fmt executable is not installed or not in \$PATH" 1>&2
|
||||
exit 12
|
||||
exit 5
|
||||
fi
|
||||
export DOCROOT_SLASH="./"
|
||||
export TAGLINE="bin/$NAME"
|
||||
@@ -131,16 +131,14 @@ NOTE: The '-v level' is passed as initial command line options to the 'markdown
|
||||
|
||||
Exit codes:
|
||||
0 all OK
|
||||
1 md2html.sh exited non-zero
|
||||
1 some internal tool exited non-zero
|
||||
2 -h and help string printed or -V and version string printed
|
||||
3 command line error
|
||||
4 bash version is < 4.2
|
||||
5 md2html.sh and/or location is not an executable file
|
||||
6 problems found with or in the topdir directory
|
||||
7 problems found with or in the topdir/YYYY directory
|
||||
8 problems found with or in the topdir/YYYY/dir directory
|
||||
>= 10 < 200 ((not used))
|
||||
>= 210 internal tool error
|
||||
5 some internal tool is not found or not an executable file
|
||||
6 problems found with or in the topdir or topdir/YYYY directory
|
||||
7 problems found with or in the entry topdir/YYYY/dir directory
|
||||
>= 10 internal error
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
@@ -401,15 +399,6 @@ if [[ ! -d $TOPDIR ]]; then
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify that we have an 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 211
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
@@ -433,6 +422,15 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
# verify that we have an 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 a non-empty readable .top file
|
||||
#
|
||||
export TOP_FILE=".top"
|
||||
@@ -522,12 +520,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_YEARS_MD"
|
||||
if [[ -e $TMP_YEARS_MD ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary years markdown file: $TMP_YEARS_MD" 1>&2
|
||||
exit 212
|
||||
exit 10
|
||||
fi
|
||||
:> "$TMP_YEARS_MD"
|
||||
if [[ ! -e $TMP_YEARS_MD ]]; then
|
||||
echo "$0: ERROR: cannot create temporary years markdown file: $TMP_YEARS_MD" 1>&2
|
||||
exit 213
|
||||
exit 11
|
||||
fi
|
||||
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
|
||||
@@ -582,19 +580,19 @@ for YYYY in $("$TAC_TOOL" "$TOP_FILE"); do
|
||||
#
|
||||
if [[ ! -e $YYYY ]]; then
|
||||
echo "$0: ERROR: YYYY does not exist: $YYYY" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -d $YYYY ]]; then
|
||||
echo "$0: ERROR: YYYY is not a directory: $YYYY" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -r $YYYY ]]; then
|
||||
echo "$0: ERROR: YYYY is not an readable directory: $YYYY" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
@@ -604,25 +602,25 @@ for YYYY in $("$TAC_TOOL" "$TOP_FILE"); do
|
||||
export YEAR_FILE="$YYYY/.year"
|
||||
if [[ ! -e $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year does not exist: $YEAR_FILE" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -f $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year is not a regular file: $YEAR_FILE" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -r $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year is not an readable file: $YEAR_FILE" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -s $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year is not a non-empty readable file: $YEAR_FILE" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE="6" # exit 6
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
@@ -694,19 +692,19 @@ for YYYY in $("$TAC_TOOL" "$TOP_FILE"); do
|
||||
#
|
||||
if [[ ! -e $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR does not exist: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE="7" # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -d $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR is not a directory: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE="7" # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -w $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR is not an writable directory: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE="7" # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
@@ -716,33 +714,33 @@ for YYYY in $("$TAC_TOOL" "$TOP_FILE"); do
|
||||
export DOT_PATH="$YYYY_DIR/.path"
|
||||
if [[ ! -s $DOT_PATH ]]; then
|
||||
echo "$0: ERROR: not a non-empty file: $DOT_PATH" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE="7" # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
DOT_PATH_CONTENT=$(< "$DOT_PATH")
|
||||
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_CODE="8" # exit 8
|
||||
EXIT_CODE="7" # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
export ENTRY_JSON="$YYYY_DIR/.entry.json"
|
||||
if [[ ! -e $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json does not exist: $ENTRY_JSON" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE="7" # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -f $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a file: $ENTRY_JSON" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE="7" # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -r $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a readable file: $ENTRY_JSON" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE="7" # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
@@ -752,7 +750,7 @@ for YYYY in $("$TAC_TOOL" "$TOP_FILE"); do
|
||||
AWARD=$(output_award "$ENTRY_JSON")
|
||||
if [[ -z $AWARD ]]; then
|
||||
echo "$0: ERROR: cannot find award in .entry.json: $ENTRY_JSON" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE="7" # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
|
||||
+71
-72
@@ -107,7 +107,7 @@ shopt -s lastpipe # run last command of a pipeline not executed in the backgroun
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.0 2024-02-05"
|
||||
export VERSION="1.0.1 2024-02-23"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -115,7 +115,7 @@ GIT_TOOL=$(type -P git)
|
||||
export GIT_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: git tool is not installed or not in \$PATH" 1>&2
|
||||
exit 10
|
||||
exit 4
|
||||
fi
|
||||
"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
status="$?"
|
||||
@@ -202,17 +202,16 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
|
||||
Exit codes:
|
||||
0 all OK
|
||||
1 cannot read input.md
|
||||
2 -h and help string printed or -V and version string printed
|
||||
3 command line error
|
||||
4 bash version is < 4.2
|
||||
5 cannot write output.html
|
||||
6 tool not found or not executable (before, pandoc wrapper, after, output tools)
|
||||
7 HTML phase file not found or not readable
|
||||
8 error in reading inc/md2html.cfg
|
||||
>= 10 < 200 internal error
|
||||
>= 200 < 209 error generated via inc/md2html.cfg
|
||||
>= 210 internal tool error
|
||||
5 some internal tool is not found or not an executable file
|
||||
6 problems found with or in the topdir or topdir/YYYY directory
|
||||
7 problems found with or in the entry topdir/YYYY/dir directory
|
||||
8 HTML phase file not found or not readable
|
||||
>= 10 < 39 internal error
|
||||
>= 40 < 200 HTML phase error
|
||||
>= 200 error generated via -e exit_code, or via inc/md2html.cfg, or awk script error
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
@@ -281,7 +280,7 @@ function global_variable_setup
|
||||
export GIT_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: git tool is not installed or not in PATH" 1>&2
|
||||
exit 10
|
||||
exit 5
|
||||
fi
|
||||
"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
status="$?"
|
||||
@@ -661,7 +660,7 @@ function debug_parameters
|
||||
#
|
||||
if [[ $# -ne 2 ]]; then
|
||||
echo "$0: ERROR: debug_parameters requires 2 args, found: $#" 1>&2
|
||||
exit 11
|
||||
exit 10
|
||||
fi
|
||||
DEBUG_LEVEL="$1"
|
||||
DBG_PREFIX="$2"
|
||||
@@ -1057,17 +1056,40 @@ export REPO_NAME
|
||||
if [[ -z $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot find top of git repo directory" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 13
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR does not exist: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 14
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR is not a directory: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 15
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to non-existent path: $TOPDIR" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to a non-directory: $TOPDIR" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export CD_FAILED
|
||||
if [[ $V_FLAG -ge 5 ]]; then
|
||||
echo "$0: debug[5]: about to: cd $TOPDIR" 1>&2
|
||||
fi
|
||||
cd "$TOPDIR" || CD_FAILED="true"
|
||||
if [[ -n $CD_FAILED ]]; then
|
||||
echo "$0: ERROR: cd $TOPDIR failed" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
# verify that we have a inc subdirectory
|
||||
@@ -1075,7 +1097,7 @@ fi
|
||||
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 16
|
||||
exit 6
|
||||
fi
|
||||
export INC_DIR="inc"
|
||||
|
||||
@@ -1084,15 +1106,15 @@ export INC_DIR="inc"
|
||||
export TOP="$TOPDIR/.top"
|
||||
if [[ ! -e $TOP ]]; then
|
||||
echo "$0: ERROR: topdir/.top does not exist: $TOP" 1>&2
|
||||
exit 17
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -f $TOP ]]; then
|
||||
echo "$0: ERROR: topdir/.top is not a file: $TOP" 1>&2
|
||||
exit 18
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -r $TOP ]]; then
|
||||
echo "$0: ERROR: topdir/.top is not a readable file: $TOP" 1>&2
|
||||
exit 19
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify we have a readable md2html.cfg file
|
||||
@@ -1102,38 +1124,15 @@ if [[ -z $MD2HTML_CFG ]]; then
|
||||
fi
|
||||
if [[ ! -e $MD2HTML_CFG ]]; then
|
||||
echo "$0: ERROR: md2html.cfg does not exist: $MD2HTML_CFG" 1>&2
|
||||
exit 20
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $MD2HTML_CFG ]]; then
|
||||
echo "$0: ERROR: md2html.cfg is not a file: $MD2HTML_CFG" 1>&2
|
||||
exit 21
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -r $MD2HTML_CFG ]]; then
|
||||
echo "$0: ERROR: md2html.cfg is not a readable file: $MD2HTML_CFG" 1>&2
|
||||
exit 22
|
||||
fi
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to non-existent path: $TOPDIR" 1>&2
|
||||
exit 23
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to a non-directory: $TOPDIR" 1>&2
|
||||
exit 24
|
||||
fi
|
||||
export CD_FAILED
|
||||
if [[ $V_FLAG -ge 5 ]]; then
|
||||
echo "$0: debug[5]: about to: cd $TOPDIR" 1>&2
|
||||
fi
|
||||
cd "$TOPDIR" || CD_FAILED="true"
|
||||
if [[ -n $CD_FAILED ]]; then
|
||||
echo "$0: ERROR: cd $TOPDIR failed" 1>&2
|
||||
exit 25
|
||||
fi
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# new parameter debugging
|
||||
@@ -1171,15 +1170,15 @@ for n in "${!OUTPUT_TOOL[@]}"; do
|
||||
VALUE="${OUTPUT_TOOL[$n]}"
|
||||
if [[ ! -e "$VALUE" ]]; then
|
||||
echo "$0: ERROR: phase ${GETOPT_PHASE} -o output tool not found: $VALUE" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f "$VALUE" ]]; then
|
||||
echo "$0: ERROR: phase ${GETOPT_PHASE} -o output tool not a file: $VALUE" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x "$VALUE" ]]; then
|
||||
echo "$0: ERROR: phase ${GETOPT_PHASE} -o output tool not an executable file: $VALUE" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -1321,15 +1320,15 @@ for n in "${!OUTPUT_TOOL[@]}"; do
|
||||
VALUE="${OUTPUT_TOOL[$n]}"
|
||||
if [[ ! -e "$VALUE" ]]; then
|
||||
echo "$0: ERROR: phase ${GETOPT_PHASE} -o output tool not found: $VALUE" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f "$VALUE" ]]; then
|
||||
echo "$0: ERROR: phase ${GETOPT_PHASE} -o output tool not a file: $VALUE" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x "$VALUE" ]]; then
|
||||
echo "$0: ERROR: phase ${GETOPT_PHASE} -o output tool not an executable file: $VALUE" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -1429,15 +1428,15 @@ for n in "${PHASE_NAME[@]}"; do
|
||||
fi
|
||||
if [[ ! -e "$HTML_PHASE_FILE" ]]; then
|
||||
echo "$0: ERROR: HTML phase $n file not found: $HTML_PHASE_FILE" 1>&2
|
||||
exit 7
|
||||
exit 8
|
||||
fi
|
||||
if [[ ! -f "$HTML_PHASE_FILE" ]]; then
|
||||
echo "$0: ERROR: HTML phase $n not a file: $HTML_PHASE_FILE" 1>&2
|
||||
exit 7
|
||||
exit 8
|
||||
fi
|
||||
if [[ ! -r "$HTML_PHASE_FILE" ]]; then
|
||||
echo "$0: ERROR: HTML phase $n not a readable file: $HTML_PHASE_FILE" 1>&2
|
||||
exit 7
|
||||
exit 8
|
||||
fi
|
||||
else
|
||||
if [[ $V_FLAG -ge 9 ]]; then
|
||||
@@ -1456,15 +1455,15 @@ if [[ -n $BEFORE_TOOL ]]; then
|
||||
fi
|
||||
if [[ ! -e "$BEFORE_TOOL" ]]; then
|
||||
echo "$0: ERROR: -b before tool not found: $BEFORE_TOOL" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f "$BEFORE_TOOL" ]]; then
|
||||
echo "$0: ERROR: -b before tool not a file: $BEFORE_TOOL" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x "$BEFORE_TOOL" ]]; then
|
||||
echo "$0: ERROR: -b before tool not an executable file: $BEFORE_TOOL" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -1478,15 +1477,15 @@ if [[ -n $PANDOC_WRAPPER ]]; then
|
||||
fi
|
||||
if [[ ! -e "$PANDOC_WRAPPER" ]]; then
|
||||
echo "$0: ERROR: -p pandoc wrapper tool not found: $PANDOC_WRAPPER" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f "$PANDOC_WRAPPER" ]]; then
|
||||
echo "$0: ERROR: -p pandoc wrapper tool not a file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x "$PANDOC_WRAPPER" ]]; then
|
||||
echo "$0: ERROR: -p pandoc wrapper tool not an executable file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -1500,15 +1499,15 @@ if [[ -n $AFTER_TOOL ]]; then
|
||||
fi
|
||||
if [[ ! -e "$AFTER_TOOL" ]]; then
|
||||
echo "$0: ERROR: -a after tool not found: $AFTER_TOOL" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f "$AFTER_TOOL" ]]; then
|
||||
echo "$0: ERROR: -a after tool not a file: $AFTER_TOOL" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x "$AFTER_TOOL" ]]; then
|
||||
echo "$0: ERROR: -a after tool not an executable file: $AFTER_TOOL" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -1547,12 +1546,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_SED_SCRIPT"
|
||||
if [[ -e $TMP_SED_SCRIPT ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary sed script: $TMP_SED_SCRIPT" 1>&2
|
||||
exit 27
|
||||
exit 14
|
||||
fi
|
||||
:> "$TMP_SED_SCRIPT"
|
||||
if [[ ! -e $TMP_SED_SCRIPT ]]; then
|
||||
echo "$0: ERROR: cannot create temporary sed script: $TMP_SED_SCRIPT" 1>&2
|
||||
exit 28
|
||||
exit 15
|
||||
fi
|
||||
|
||||
# load the sed script with sed commands from any "-s token=value"
|
||||
@@ -1590,12 +1589,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_PHASE"
|
||||
if [[ -e $TMP_PHASE ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary HTML file: $TMP_PHASE" 1>&2
|
||||
exit 29
|
||||
exit 15
|
||||
fi
|
||||
:> "$TMP_PHASE"
|
||||
if [[ ! -e $TMP_PHASE ]]; then
|
||||
echo "$0: ERROR: cannot create temporary HTML file: $TMP_PHASE" 1>&2
|
||||
exit 30
|
||||
exit 17
|
||||
fi
|
||||
elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary HTML file is not formed: $TMP_PHASE" 1>&2
|
||||
@@ -1617,12 +1616,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_INDEX_HTML"
|
||||
if [[ -e $TMP_INDEX_HTML ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary index HTML file: $TMP_INDEX_HTML" 1>&2
|
||||
exit 31
|
||||
exit 18
|
||||
fi
|
||||
:> "$TMP_INDEX_HTML"
|
||||
if [[ ! -e $TMP_INDEX_HTML ]]; then
|
||||
echo "$0: ERROR: cannot create temporary index HTML file: $TMP_PHASE" 1>&2
|
||||
exit 32
|
||||
exit 19
|
||||
fi
|
||||
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
|
||||
@@ -1639,12 +1638,12 @@ if [[ $INPUT_MD == - ]]; then
|
||||
rm -f "$TMP_INPUT_MD"
|
||||
if [[ -e $TMP_INPUT_MD ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary stdin file: $TMP_INPUT_MD" 1>&2
|
||||
exit 33
|
||||
exit 20
|
||||
fi
|
||||
:> "$TMP_INPUT_MD"
|
||||
if [[ ! -e $TMP_INPUT_MD ]]; then
|
||||
echo "$0: ERROR: cannot create temporary stdin file: $TMP_INPUT_MD" 1>&2
|
||||
exit 34
|
||||
exit 21
|
||||
fi
|
||||
|
||||
# capture standard input into the temporary stdin file
|
||||
@@ -1656,7 +1655,7 @@ if [[ $INPUT_MD == - ]]; then
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: cat into stdin file: $TMP_INPUT_MD failed, error code: $status" 1>&2
|
||||
exit 35
|
||||
exit 22
|
||||
fi
|
||||
|
||||
# replace 'input.md' of - with temporary stdin file
|
||||
|
||||
+74
-79
@@ -55,7 +55,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.4 2024-02-11"
|
||||
export VERSION="1.4.1 2024-02-23"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -63,7 +63,7 @@ GIT_TOOL=$(type -P git)
|
||||
export GIT_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: git tool is not installed or not in \$PATH" 1>&2
|
||||
exit 210
|
||||
exit 5
|
||||
fi
|
||||
"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
status="$?"
|
||||
@@ -107,14 +107,15 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
|
||||
Exit codes:
|
||||
0 all OK
|
||||
1 pandoc exited non-zero
|
||||
1 some internal tool exited non-zero
|
||||
2 -h and help string printed or -V and version string printed
|
||||
3 command line error
|
||||
4 bash version is < 4.2
|
||||
5 YYYY/dir is not a entry directory
|
||||
6 pandoc tool not found or not executable
|
||||
>= 10 < 210 ((not used))
|
||||
>= 210 internal tool error
|
||||
5 some internal tool is not found or not an executable file
|
||||
6 problems found with or in the topdir or topdir/YYYY directory
|
||||
7 problems found with or in the entry topdir/YYYY/dir directory
|
||||
8 error in author/author_handle.json file
|
||||
>= 10 internal error
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
@@ -410,55 +411,28 @@ export REPO_NAME
|
||||
if [[ -z $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot find top of git repo directory" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 211
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR does not exist: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 212
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR is not a directory: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 213
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify that we have an author subdirectory
|
||||
#
|
||||
export AUTHOR_PATH="$TOPDIR/author"
|
||||
if [[ ! -d $AUTHOR_PATH ]]; then
|
||||
echo "$0: ERROR: author is not a directory under topdir: $AUTHOR_PATH" 1>&2
|
||||
exit 214
|
||||
fi
|
||||
export AUTHOR_DIR="author"
|
||||
|
||||
# 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 215
|
||||
fi
|
||||
export INC_DIR="inc"
|
||||
|
||||
# verify that we have an 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 216
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to non-existent path: $TOPDIR" 1>&2
|
||||
exit 217
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to a non-directory: $TOPDIR" 1>&2
|
||||
exit 218
|
||||
exit 6
|
||||
fi
|
||||
export CD_FAILED
|
||||
if [[ $V_FLAG -ge 5 ]]; then
|
||||
@@ -467,103 +441,124 @@ fi
|
||||
cd "$TOPDIR" || CD_FAILED="true"
|
||||
if [[ -n $CD_FAILED ]]; then
|
||||
echo "$0: ERROR: cd $TOPDIR failed" 1>&2
|
||||
exit 219
|
||||
exit 6
|
||||
fi
|
||||
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
|
||||
# verify that we have an author subdirectory
|
||||
#
|
||||
# ENTRY_PATH must be in YYYY/dir form
|
||||
# YYYY must be a directory
|
||||
# YYYY must be a writable directory
|
||||
# YYYY/.year must be a non-empty file
|
||||
# YYYY/dir must be a directory
|
||||
# YYYY/dir/.path must be a non-empty file
|
||||
# ENTRY_PATH must match the contents of YYYY/dir/.path
|
||||
# YYYY/dir/.entry.json must be a non-empty file
|
||||
export AUTHOR_PATH="$TOPDIR/author"
|
||||
if [[ ! -d $AUTHOR_PATH ]]; then
|
||||
echo "$0: ERROR: author is not a directory under topdir: $AUTHOR_PATH" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export AUTHOR_DIR="author"
|
||||
|
||||
# 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 an 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
|
||||
#
|
||||
if [[ ! -d $ENTRY_PATH ]]; then
|
||||
echo "$0: ERROR: arg is not a directory: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -w $ENTRY_PATH ]]; then
|
||||
echo "$0: ERROR: arg is not a writable directory: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
export YEAR_DIR=${ENTRY_PATH%%/*}
|
||||
if [[ -z $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: arg not in YYYY/dir form: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
export ENTRY_DIR=${ENTRY_PATH#*/}
|
||||
if [[ -z $ENTRY_DIR ]]; then
|
||||
echo "$0: ERROR: arg: $ENTRY_PATH not in $YEAR_DIR/dir form: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
if [[ $ENTRY_DIR = */* ]]; then
|
||||
echo "$0: ERROR: dir from arg: $ENTRY_PATH contains a /: $ENTRY_DIR" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -d $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY from arg: $ENTRY_PATH is not a directory: $YEAR_DIR" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
export ENTRY_ID="${YEAR_DIR}_${ENTRY_DIR}"
|
||||
export DOT_YEAR="$YEAR_DIR/.year"
|
||||
if [[ ! -s $DOT_YEAR ]]; then
|
||||
echo "$0: ERROR: not a non-empty file: $DOT_YEAR" 1>&2
|
||||
exit 5
|
||||
exit 6
|
||||
fi
|
||||
# Now that we have moved to topdir, form and verify YYYY_DIR is a writable directory
|
||||
export YYYY_DIR="$YEAR_DIR/$ENTRY_DIR"
|
||||
if [[ ! -e $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY/dir from arg: $ENTRY_PATH does not exist: $YYYY_DIR" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -d $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY/dir from arg: $ENTRY_PATH is not a directory: $YYYY_DIR" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -w $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY/dir from arg: $ENTRY_PATH is not a writable directory: $YYYY_DIR" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
export DOT_PATH="$YYYY_DIR/.path"
|
||||
if [[ ! -s $DOT_PATH ]]; then
|
||||
echo "$0: ERROR: not a non-empty file: $DOT_PATH" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
DOT_PATH_CONTENT=$(< "$DOT_PATH")
|
||||
if [[ $ENTRY_PATH != "$DOT_PATH_CONTENT" ]]; then
|
||||
echo "$0: ERROR: arg: $ENTRY_PATH does not match $DOT_PATH contents: $DOT_PATH_CONTENT" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
export ENTRY_JSON="$YYYY_DIR/.entry.json"
|
||||
if [[ ! -e $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json does not exist: $ENTRY_JSON" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -f $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a file: $ENTRY_JSON" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -r $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a readable file: $ENTRY_JSON" 1>&2
|
||||
exit 5
|
||||
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 6
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: pandoc wrapper tool is not a file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: pandoc wrapper tool is not an executable file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# parameter debugging
|
||||
@@ -604,7 +599,7 @@ AUTHOR_HANDLE_SET=$(output_author_handles "$ENTRY_JSON")
|
||||
status="$?"
|
||||
if [[ $status -ne 0 || -z $AUTHOR_HANDLE_SET ]]; then
|
||||
echo "$0: ERROR: unable to obtain any author handles from: $ENTRY_JSON" 1>&2
|
||||
exit 220
|
||||
exit 7
|
||||
fi
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: author handles found in $ENTRY_JSON start below" 1>&2
|
||||
@@ -624,15 +619,15 @@ for author_handle in $AUTHOR_HANDLE_SET; do
|
||||
#
|
||||
if [[ ! -e $AUTHOR_HANDLE_JSON ]]; then
|
||||
echo "$0: ERROR: for author handle: $author_handle author JSON file not found: $AUTHOR_HANDLE_JSON" 1>&2
|
||||
exit 221
|
||||
exit 8
|
||||
fi
|
||||
if [[ ! -f $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: for author handle: $author_handle author JSON is not a file: $AUTHOR_HANDLE_JSON" 1>&2
|
||||
exit 222
|
||||
exit 8
|
||||
fi
|
||||
if [[ ! -r $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: for author handle: $author_handle author JSON is not a readable file: $AUTHOR_HANDLE_JSON" 1>&2
|
||||
exit 223
|
||||
exit 8
|
||||
fi
|
||||
if [[ $V_FLAG -ge 5 ]]; then
|
||||
echo "$0: debug[5]: for author handle: $author_handle found a readable author JSON file: $AUTHOR_HANDLE_JSON" 1>&2
|
||||
@@ -644,7 +639,7 @@ for author_handle in $AUTHOR_HANDLE_SET; do
|
||||
status="$?"
|
||||
if [[ $status -ne 0 || -z $ENTRY_ID_FOUND ]]; then
|
||||
echo "$0: ERROR: entry id: $ENTRY_ID not found in author JSON file: $AUTHOR_HANDLE_JSON, status: $status" 1>&2
|
||||
exit 224
|
||||
exit 8
|
||||
fi
|
||||
if [[ $V_FLAG -ge 7 ]]; then
|
||||
echo "$0: debug[7]: readable author JSON file: $AUTHOR_HANDLE_JSON mentions entry id: $ENTRY_ID" 1>&2
|
||||
@@ -656,7 +651,7 @@ for author_handle in $AUTHOR_HANDLE_SET; do
|
||||
status="$?"
|
||||
if [[ $status -ne 0 || -z $FULL_NAME ]]; then
|
||||
echo "$0: ERROR: author JSON file: $AUTHOR_HANDLE_JSON as no FULL NAME, status: $status" 1>&2
|
||||
exit 225
|
||||
exit 8
|
||||
fi
|
||||
if [[ $V_FLAG -ge 7 ]]; then
|
||||
echo "$0: debug[7]: author JSON file: $AUTHOR_HANDLE_JSON Full Name: $FULL_NAME" 1>&2
|
||||
@@ -668,7 +663,7 @@ for author_handle in $AUTHOR_HANDLE_SET; do
|
||||
status="$?"
|
||||
if [[ $status -ne 0 || -z $LOCATION_CODE ]]; then
|
||||
echo "$0: ERROR: author JSON file: $AUTHOR_HANDLE_JSON as no Location Code, status: $status" 1>&2
|
||||
exit 226
|
||||
exit 8
|
||||
fi
|
||||
if [[ $V_FLAG -ge 7 ]]; then
|
||||
echo "$0: debug[7]: author JSON file: $AUTHOR_HANDLE_JSON Location Code: $LOCATION_CODE" 1>&2
|
||||
@@ -695,12 +690,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_FILE"
|
||||
if [[ -e $TMP_FILE ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary markdown file: $TMP_FILE" 1>&2
|
||||
exit 227
|
||||
exit 10
|
||||
fi
|
||||
:> "$TMP_FILE"
|
||||
if [[ ! -e $TMP_FILE ]]; then
|
||||
echo "$0: ERROR: cannot create temporary markdown file: $TMP_FILE" 1>&2
|
||||
exit 228
|
||||
exit 11
|
||||
fi
|
||||
elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary markdown file is not used: $TMP_FILE" 1>&2
|
||||
@@ -738,7 +733,7 @@ for author_handle in $AUTHOR_HANDLE_SET; do
|
||||
status="$?"
|
||||
if [[ $status -ne 0 || -z $FULL_NAME ]]; then
|
||||
echo "$0: ERROR: author JSON file: $AUTHOR_HANDLE_JSON as no FULL NAME, status: $status" 1>&2
|
||||
exit 229
|
||||
exit 12
|
||||
fi
|
||||
|
||||
# obtain the Location Code from the author handle JSON file
|
||||
@@ -747,7 +742,7 @@ for author_handle in $AUTHOR_HANDLE_SET; do
|
||||
status="$?"
|
||||
if [[ $status -ne 0 || -z $LOCATION_CODE ]]; then
|
||||
echo "$0: ERROR: author JSON file: $AUTHOR_HANDLE_JSON as no Location Code, status: $status" 1>&2
|
||||
exit 230
|
||||
exit 13
|
||||
fi
|
||||
|
||||
# write this author's information
|
||||
@@ -782,7 +777,7 @@ if [[ -z $NOOP ]]; then
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: pandoc failed, error: $status" 1>&2
|
||||
exit 231
|
||||
exit 1
|
||||
fi
|
||||
echo
|
||||
echo "<!-- END: next line ends content generated by: bin/$NAME -->"
|
||||
|
||||
@@ -55,7 +55,7 @@ shopt -s globstar # enable '**' to match all files and zero or more directories
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.1 2024-02-11"
|
||||
export VERSION="1.1.1 2024-02-23"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -63,7 +63,7 @@ GIT_TOOL=$(type -P git)
|
||||
export GIT_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: git tool is not installed or is not in PATH" 1>&2
|
||||
exit 210
|
||||
exit 5
|
||||
fi
|
||||
"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
status="$?"
|
||||
@@ -113,8 +113,7 @@ Exit codes:
|
||||
4 bash version is < 4.2
|
||||
5 YYYY/dir is not a entry directory
|
||||
6 pandoc tool not found or not executable
|
||||
>= 10 < 210 ((not used))
|
||||
>= 210 internal tool error
|
||||
>= 10 internal error
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
@@ -210,55 +209,28 @@ export REPO_NAME
|
||||
if [[ -z $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot find top of git repo directory" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 211
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR does not exist: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 212
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR is not a directory: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 213
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify that we have an author subdirectory
|
||||
#
|
||||
export AUTHOR_PATH="$TOPDIR/author"
|
||||
if [[ ! -d $AUTHOR_PATH ]]; then
|
||||
echo "$0: ERROR: author is not a directory under topdir: $AUTHOR_PATH" 1>&2
|
||||
exit 214
|
||||
fi
|
||||
export AUTHOR_DIR="author"
|
||||
|
||||
# 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 215
|
||||
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 216
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to non-existent path: $TOPDIR" 1>&2
|
||||
exit 217
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to a non-directory: $TOPDIR" 1>&2
|
||||
exit 218
|
||||
exit 6
|
||||
fi
|
||||
export CD_FAILED
|
||||
if [[ $V_FLAG -ge 5 ]]; then
|
||||
@@ -267,96 +239,113 @@ fi
|
||||
cd "$TOPDIR" || CD_FAILED="true"
|
||||
if [[ -n $CD_FAILED ]]; then
|
||||
echo "$0: ERROR: cd $TOPDIR failed" 1>&2
|
||||
exit 219
|
||||
exit 6
|
||||
fi
|
||||
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
|
||||
# verify that we have an author subdirectory
|
||||
#
|
||||
# ENTRY_PATH must be in YYYY/dir form
|
||||
# YYYY must be a directory
|
||||
# YYYY must be a writable directory
|
||||
# YYYY/.year must be a non-empty file
|
||||
# YYYY/dir must be a directory
|
||||
# YYYY/dir/.path must be a non-empty file
|
||||
# ENTRY_PATH must match the contents of YYYY/dir/.path
|
||||
# YYYY/dir/.entry.json must be a non-empty file
|
||||
export AUTHOR_PATH="$TOPDIR/author"
|
||||
if [[ ! -d $AUTHOR_PATH ]]; then
|
||||
echo "$0: ERROR: author is not a directory under topdir: $AUTHOR_PATH" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export AUTHOR_DIR="author"
|
||||
|
||||
# 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
|
||||
#
|
||||
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
|
||||
#
|
||||
if [[ ! -d $ENTRY_PATH ]]; then
|
||||
echo "$0: ERROR: arg is not a directory: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -w $ENTRY_PATH ]]; then
|
||||
echo "$0: ERROR: arg is not a writable directory: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
export YEAR_DIR=${ENTRY_PATH%%/*}
|
||||
if [[ -z $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: arg not in YYYY/dir form: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
export ENTRY_DIR=${ENTRY_PATH#*/}
|
||||
if [[ -z $ENTRY_DIR ]]; then
|
||||
echo "$0: ERROR: arg: $ENTRY_PATH not in $YEAR_DIR/dir form: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
if [[ $ENTRY_DIR = */* ]]; then
|
||||
echo "$0: ERROR: dir from arg: $ENTRY_PATH contains a /: $ENTRY_DIR" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -d $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY from arg: $ENTRY_PATH is not a directory: $YEAR_DIR" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
export ENTRY_ID="${YEAR_DIR}_${ENTRY_DIR}"
|
||||
export DOT_YEAR="$YEAR_DIR/.year"
|
||||
if [[ ! -s $DOT_YEAR ]]; then
|
||||
echo "$0: ERROR: not a non-empty file: $DOT_YEAR" 1>&2
|
||||
exit 5
|
||||
exit 6
|
||||
fi
|
||||
# Now that we have moved to topdir, form and verify YYYY_DIR is a writable directory
|
||||
export YYYY_DIR="$YEAR_DIR/$ENTRY_DIR"
|
||||
if [[ ! -e $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY/dir from arg: $ENTRY_PATH does not exist: $YYYY_DIR" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -d $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY/dir from arg: $ENTRY_PATH is not a directory: $YYYY_DIR" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -w $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY/dir from arg: $ENTRY_PATH is not a writable directory: $YYYY_DIR" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -d $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY/dir from arg: $ENTRY_PATH is not a directory: $YYYY_DIR" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
export DOT_PATH="$YYYY_DIR/.path"
|
||||
if [[ ! -s $DOT_PATH ]]; then
|
||||
echo "$0: ERROR: not a non-empty file: $DOT_PATH" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
DOT_PATH_CONTENT=$(< "$DOT_PATH")
|
||||
if [[ $ENTRY_PATH != "$DOT_PATH_CONTENT" ]]; then
|
||||
echo "$0: ERROR: arg: $ENTRY_PATH does not match $DOT_PATH contents: $DOT_PATH_CONTENT" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
export ENTRY_JSON="$YYYY_DIR/.entry.json"
|
||||
if [[ ! -e $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json does not exist: $ENTRY_JSON" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -f $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a regular file: $ENTRY_JSON" 1>&2
|
||||
exit 5
|
||||
echo "$0: ERROR: .entry.json is not a file: $ENTRY_JSON" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -r $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a readable file: $ENTRY_JSON" 1>&2
|
||||
exit 5
|
||||
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 6
|
||||
@@ -439,12 +428,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_FILE"
|
||||
if [[ -e $TMP_FILE ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary markdown file: $TMP_FILE" 1>&2
|
||||
exit 220
|
||||
exit 10
|
||||
fi
|
||||
:> "$TMP_FILE"
|
||||
if [[ ! -e $TMP_FILE ]]; then
|
||||
echo "$0: ERROR: cannot create temporary markdown file: $TMP_FILE" 1>&2
|
||||
exit 221
|
||||
exit 11
|
||||
fi
|
||||
elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary markdown file is not used: $TMP_FILE" 1>&2
|
||||
@@ -461,12 +450,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_MANIFEST"
|
||||
if [[ -e $TMP_MANIFEST ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary manifest file: $TMP_MANIFEST" 1>&2
|
||||
exit 222
|
||||
exit 12
|
||||
fi
|
||||
:> "$TMP_MANIFEST"
|
||||
if [[ ! -e $TMP_MANIFEST ]]; then
|
||||
echo "$0: ERROR: cannot create temporary manifest file: $TMP_MANIFEST" 1>&2
|
||||
exit 223
|
||||
exit 13
|
||||
fi
|
||||
elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary manifest file is not used: $TMP_MANIFEST" 1>&2
|
||||
@@ -479,7 +468,7 @@ if [[ -z $NOOP ]]; then
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: manifest.entry.json.awk failed, error: $status" 1>&2
|
||||
exit 224
|
||||
exit 1
|
||||
fi
|
||||
{
|
||||
# load numerically sorted inventory_order lines into the temporary markdown file
|
||||
@@ -514,7 +503,7 @@ if [[ -z $NOOP ]]; then
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: pandoc failed, error: $status" 1>&2
|
||||
exit 225
|
||||
exit 1
|
||||
fi
|
||||
echo
|
||||
echo "<!-- END: next line ends content generated by: bin/$NAME -->"
|
||||
|
||||
+42
-54
@@ -56,7 +56,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.0 2024-02-12"
|
||||
export VERSION="1.0.1 2024-02-23"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -64,7 +64,7 @@ GIT_TOOL=$(type -P git)
|
||||
export GIT_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: git tool is not installed or not in \$PATH" 1>&2
|
||||
exit 210
|
||||
exit 5
|
||||
fi
|
||||
"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
status="$?"
|
||||
@@ -107,15 +107,14 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N]
|
||||
|
||||
Exit codes:
|
||||
0 all OK
|
||||
1 some internal tool exited non-zero
|
||||
2 -h and help string printed or -V and version string printed
|
||||
3 command line error
|
||||
4 bash version is < 4.2
|
||||
5 YYYY is not a year directory
|
||||
6 subst.year-navbar.awk tool or pandoc wrapper not found
|
||||
7 cannot find a non-empty or read .year file
|
||||
8 entry under year YYYY is not in proper form
|
||||
>= 10 < 210 ((not used))
|
||||
>= 210 internal tool error
|
||||
5 some internal tool is not found or not an executable file
|
||||
6 problems found with or in the topdir or topdir/YYYY directory
|
||||
7 problems found with or in the entry topdir/YYYY/dir directory
|
||||
>= 10 internal error
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
@@ -328,28 +327,28 @@ export REPO_NAME
|
||||
if [[ -z $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot find top of git repo directory" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 211
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR does not exist: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 212
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR is not a directory: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 213
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to non-existent path: $TOPDIR" 1>&2
|
||||
exit 217
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to a non-directory: $TOPDIR" 1>&2
|
||||
exit 218
|
||||
exit 6
|
||||
fi
|
||||
export CD_FAILED
|
||||
if [[ $V_FLAG -ge 5 ]]; then
|
||||
@@ -358,7 +357,7 @@ fi
|
||||
cd "$TOPDIR" || CD_FAILED="true"
|
||||
if [[ -n $CD_FAILED ]]; then
|
||||
echo "$0: ERROR: cd $TOPDIR failed" 1>&2
|
||||
exit 219
|
||||
exit 6
|
||||
fi
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
@@ -368,26 +367,26 @@ fi
|
||||
#
|
||||
if [[ ! -e $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: pandoc wrapper tool does not exist: $PANDOC_WRAPPER" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: pandoc wrapper tool is not a file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $PANDOC_WRAPPER ]]; then
|
||||
echo "$0: ERROR: pandoc wrapper tool is not an executable file: $PANDOC_WRAPPER" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# verify that YYYY is a entry directory
|
||||
#
|
||||
if [[ ! -d $YYYY ]]; then
|
||||
echo "$0: ERROR: arg is not a directory: $YYYY" 1>&2
|
||||
exit 5
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -r $YYYY ]]; then
|
||||
echo "$0: ERROR: arg is not a writable directory: $YYYY" 1>&2
|
||||
exit 5
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify we have a non-empty readable .top file
|
||||
@@ -415,19 +414,19 @@ fi
|
||||
export YEAR_FILE="$YYYY/.year"
|
||||
if [[ ! -e $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year does not exist: $YEAR_FILE" 1>&2
|
||||
exit 7
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -f $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year is not a regular file: $YEAR_FILE" 1>&2
|
||||
exit 7
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -r $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year is not an readable file: $YEAR_FILE" 1>&2
|
||||
exit 7
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -s $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year is not a non-empty readable file: $YEAR_FILE" 1>&2
|
||||
exit 7
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# determine The N-th IOCCC string
|
||||
@@ -435,13 +434,13 @@ fi
|
||||
LINE_NUM=$(sed -n "/$YYYY/=" "$TOP_FILE" | head -1)
|
||||
if [[ -z $LINE_NUM ]]; then
|
||||
echo "$0: ERROR: cannot determine line number in $TOP_FILE for year: $YYYY" 1>&2
|
||||
exit 220
|
||||
exit 10
|
||||
fi
|
||||
ORDINAL=$(output_ordinal "$LINE_NUM")
|
||||
export ORDINAL
|
||||
if [[ -z $ORDINAL ]]; then
|
||||
echo "$0: ERROR: cannot determine ordinal for: $LINE_NUM" 1>&2
|
||||
exit 221
|
||||
exit 11
|
||||
fi
|
||||
|
||||
# parameter debugging
|
||||
@@ -486,12 +485,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_FILE"
|
||||
if [[ -e $TMP_FILE ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary markdown file: $TMP_FILE" 1>&2
|
||||
exit 227
|
||||
exit 12
|
||||
fi
|
||||
:> "$TMP_FILE"
|
||||
if [[ ! -e $TMP_FILE ]]; then
|
||||
echo "$0: ERROR: cannot create temporary markdown file: $TMP_FILE" 1>&2
|
||||
exit 228
|
||||
exit 13
|
||||
fi
|
||||
elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary markdown file is not used: $TMP_FILE" 1>&2
|
||||
@@ -526,42 +525,31 @@ for YYYY_DIR in $(< "$YEAR_FILE"); do
|
||||
|
||||
# parse YYYY_DIR
|
||||
#
|
||||
if [[ ! -e $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR does not exist: $YYYY_DIR" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -d $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR is not a directory: $YYYY_DIR" 1>&2
|
||||
exit 8
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -w $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR is not a writable directory: $YYYY_DIR" 1>&2
|
||||
exit 8
|
||||
exit 7
|
||||
fi
|
||||
export YEAR_DIR=${YYYY_DIR%%/*}
|
||||
if [[ -z $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR not in YYYY/dir form: $YYYY_DIR" 1>&2
|
||||
exit 8
|
||||
exit 7
|
||||
fi
|
||||
export ENTRY_DIR=${YYYY_DIR#*/}
|
||||
if [[ -z $ENTRY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR not in $YEAR_DIR/dir form: $YYYY_DIR" 1>&2
|
||||
exit 8
|
||||
exit 7
|
||||
fi
|
||||
if [[ $ENTRY_DIR = */* ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR: $YYYY_DIR dir contains a /: $ENTRY_DIR" 1>&2
|
||||
exit 8
|
||||
fi
|
||||
|
||||
# verify that YYYY_DIR is a writable directory
|
||||
#
|
||||
if [[ ! -e $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR does not exist: $YYYY_DIR" 1>&2
|
||||
exit 8
|
||||
fi
|
||||
if [[ ! -d $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR is not a directory: $YYYY_DIR" 1>&2
|
||||
exit 8
|
||||
fi
|
||||
if [[ ! -w $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR is not an writable directory: $YYYY_DIR" 1>&2
|
||||
exit 8
|
||||
exit 7
|
||||
fi
|
||||
|
||||
# verify YYYY/dir/.path
|
||||
@@ -569,25 +557,25 @@ for YYYY_DIR in $(< "$YEAR_FILE"); do
|
||||
export DOT_PATH="$YYYY_DIR/.path"
|
||||
if [[ ! -s $DOT_PATH ]]; then
|
||||
echo "$0: ERROR: not a non-empty file: $DOT_PATH" 1>&2
|
||||
exit 8
|
||||
exit 7
|
||||
fi
|
||||
DOT_PATH_CONTENT=$(< "$DOT_PATH")
|
||||
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 8
|
||||
exit 7
|
||||
fi
|
||||
export ENTRY_JSON="$YYYY_DIR/.entry.json"
|
||||
if [[ ! -e $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json does not exist: $ENTRY_JSON" 1>&2
|
||||
exit 8
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -f $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a file: $ENTRY_JSON" 1>&2
|
||||
exit 8
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -r $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a readable file: $ENTRY_JSON" 1>&2
|
||||
exit 8
|
||||
exit 7
|
||||
fi
|
||||
|
||||
# determine the award for this entry
|
||||
@@ -595,7 +583,7 @@ for YYYY_DIR in $(< "$YEAR_FILE"); do
|
||||
AWARD=$(output_award "$ENTRY_JSON")
|
||||
if [[ -z $AWARD ]]; then
|
||||
echo "$0: ERROR: cannot find award in .entry.json: $ENTRY_JSON" 1>&2
|
||||
exit 8
|
||||
exit 7
|
||||
fi
|
||||
|
||||
# output markdown for this entry
|
||||
@@ -637,7 +625,7 @@ if [[ -z $NOOP ]]; then
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: pandoc failed, error: $status" 1>&2
|
||||
exit 231
|
||||
exit 1
|
||||
fi
|
||||
echo
|
||||
echo "<!-- END: next line ends content generated by: bin/$NAME -->"
|
||||
|
||||
+42
-45
@@ -56,7 +56,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.4 2024-02-05"
|
||||
export VERSION="1.4.1 2024-02-23"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -65,7 +65,7 @@ GIT_TOOL=$(type -P git)
|
||||
export GIT_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: git tool is not installed or not in \$PATH" 1>&2
|
||||
exit 210
|
||||
exit 5
|
||||
fi
|
||||
"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
status="$?"
|
||||
@@ -77,7 +77,6 @@ PANDOC_TOOL=$(type -P pandoc)
|
||||
if [[ -z $PANDOC_TOOL ]]; then
|
||||
PANDOC_TOOL="/opt/homebrew/bin/pandoc"
|
||||
fi
|
||||
export PANDOC_WRAPPER="bin/pandoc_wapper.sh"
|
||||
unset PANDOC_OPTION
|
||||
declare -ag PANDOC_OPTION
|
||||
PANDOC_OPTION+=("-f")
|
||||
@@ -121,10 +120,9 @@ Exit codes:
|
||||
2 -h and help string printed or -V and version string printed
|
||||
3 command line error
|
||||
4 bash version is < 4.2
|
||||
5 file.md file not found or not readable file
|
||||
6 pandoc tool not found or not executable
|
||||
>= 10 < 210 ((not used))
|
||||
>= 210 internal tool error
|
||||
5 some internal tool is not found or not an executable file
|
||||
6 problems found with or in the topdir or topdir/YYYY directory
|
||||
>= 10 internal error
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
@@ -204,19 +202,19 @@ fi
|
||||
#
|
||||
if [[ ! -e $MARKDOWN_INPUT ]]; then
|
||||
echo "$0: ERROR: markdown input file does not exist: $MARKDOWN_INPUT" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -f $MARKDOWN_INPUT ]]; then
|
||||
echo "$0: ERROR: markdown input is not a file: $MARKDOWN_INPUT" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -r $MARKDOWN_INPUT ]]; then
|
||||
echo "$0: ERROR: markdown input is not a readable file: $MARKDOWN_INPUT" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -x $PANDOC_TOOL ]]; then
|
||||
echo "$0: ERROR: cannot find an executable pandoc tool: $PANDOC_TOOL" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# verify that we have a topdir directory
|
||||
@@ -225,55 +223,28 @@ REPO_NAME=$(basename "$REPO_URL")
|
||||
if [[ -z $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot find top of git repo directory" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 211
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR does not exist: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 212
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR is not a directory: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 213
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify that we have an author subdirectory
|
||||
#
|
||||
export AUTHOR_PATH="$TOPDIR/author"
|
||||
if [[ ! -d $AUTHOR_PATH ]]; then
|
||||
echo "$0: ERROR: author is not a directory under topdir: $AUTHOR_PATH" 1>&2
|
||||
exit 214
|
||||
fi
|
||||
export AUTHOR_DIR="author"
|
||||
|
||||
# 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 215
|
||||
fi
|
||||
export INC_DIR="inc"
|
||||
|
||||
# verify that we have an 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 216
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to non-existent path: $TOPDIR" 1>&2
|
||||
exit 217
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to a non-directory: $TOPDIR" 1>&2
|
||||
exit 218
|
||||
exit 6
|
||||
fi
|
||||
export CD_FAILED
|
||||
if [[ $V_FLAG -ge 5 ]]; then
|
||||
@@ -282,12 +253,39 @@ fi
|
||||
cd "$TOPDIR" || CD_FAILED="true"
|
||||
if [[ -n $CD_FAILED ]]; then
|
||||
echo "$0: ERROR: cd $TOPDIR failed" 1>&2
|
||||
exit 219
|
||||
exit 6
|
||||
fi
|
||||
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"
|
||||
if [[ ! -d $AUTHOR_PATH ]]; then
|
||||
echo "$0: ERROR: author is not a directory under topdir: $AUTHOR_PATH" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export AUTHOR_DIR="author"
|
||||
|
||||
# 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 an 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
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -297,7 +295,6 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: PANDOC_TOOL=$PANDOC_TOOL" 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]: REPO_URL=$REPO_URL" 1>&2
|
||||
echo "$0: debug[3]: NOOP=$NOOP" 1>&2
|
||||
echo "$0: debug[3]: DO_NOT_PROCESS=$DO_NOT_PROCESS" 1>&2
|
||||
|
||||
+77
-100
@@ -58,7 +58,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 2024-02-11"
|
||||
export VERSION="1.1.1 2024-02-23"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -66,7 +66,7 @@ GIT_TOOL=$(type -P git)
|
||||
export GIT_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: git tool is not installed or not in \$PATH" 1>&2
|
||||
exit 10
|
||||
exit 5
|
||||
fi
|
||||
"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
status="$?"
|
||||
@@ -136,16 +136,14 @@ NOTE: Any '-t tagline', '-T md2html.sh', '-p tool', '-u repo_url', '-w site_url'
|
||||
|
||||
Exit codes:
|
||||
0 all OK
|
||||
1 some tool exited non-zero
|
||||
1 some internal tool exited non-zero
|
||||
2 -h and help string printed or -V and version string printed
|
||||
3 command line error
|
||||
4 bash version is < 4.2
|
||||
5 tool and/or md2html.sh is not an executable file
|
||||
6 problems found with or in the topdir directory
|
||||
7 problems found with or in the topdir/YYYY directory
|
||||
8 problems found with or in the topdir/YYYY/dir directory
|
||||
>= 10 < 200 internal error
|
||||
>= 200 ((not used))
|
||||
5 some internal tool is not found or not an executable file
|
||||
6 problems found with or in the topdir or topdir/YYYY directory
|
||||
7 problems found with or in the entry topdir/YYYY/dir directory
|
||||
>= 10 internal error
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
@@ -268,58 +266,6 @@ if [[ -n $TAGLINE ]]; then
|
||||
TOOL_OPTION+=("$TAGLINE")
|
||||
fi
|
||||
|
||||
# parse the ENTRY_PATH arg
|
||||
#
|
||||
# verify that ENTRY_PATH is in proper form
|
||||
#
|
||||
# Also obtain the YEAR_DIR and ENTRY_DIR from ENTRY_PATH.
|
||||
#
|
||||
if [[ -z $ENTRY_PATH ]]; then
|
||||
echo "$0: ERROR: arg is an empty string" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -d $ENTRY_PATH ]]; then
|
||||
echo "$0: ERROR: arg is not a directory: $ENTRY_PATH" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -w $ENTRY_PATH ]]; then
|
||||
echo "$0: ERROR: arg is not a writable directory: $ENTRY_PATH" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
export YEAR_DIR=${ENTRY_PATH%%/*}
|
||||
if [[ -z $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: arg not in YYYY/dir form: $ENTRY_PATH" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -d $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY from arg: $ENTRY_PATH is not a directory: $YEAR_DIR" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
export ENTRY_DIR=${ENTRY_PATH#*/}
|
||||
if [[ -z $ENTRY_DIR ]]; then
|
||||
echo "$0: ERROR: arg: $ENTRY_PATH not in $YEAR_DIR/dir form: $ENTRY_PATH" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
if [[ $ENTRY_DIR = */* ]]; then
|
||||
echo "$0: ERROR: dir from arg: $ENTRY_PATH contains a /: $ENTRY_DIR" 1>&2
|
||||
exit 3
|
||||
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
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_URL")
|
||||
@@ -363,24 +309,39 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
# perform tests on YYYY_DIR (YYYY/dir) as a entry directory
|
||||
# verify that ENTRY_PATH is a entry directory
|
||||
#
|
||||
if [[ ! -d $ENTRY_PATH ]]; then
|
||||
echo "$0: ERROR: arg is not a directory: $ENTRY_PATH" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -w $ENTRY_PATH ]]; then
|
||||
echo "$0: ERROR: arg is not a writable directory: $ENTRY_PATH" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
export YEAR_DIR=${ENTRY_PATH%%/*}
|
||||
if [[ -z $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: arg not in YYYY/dir form: $ENTRY_PATH" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
export ENTRY_DIR=${ENTRY_PATH#*/}
|
||||
if [[ -z $ENTRY_DIR ]]; then
|
||||
echo "$0: ERROR: arg: $ENTRY_PATH not in $YEAR_DIR/dir form: $ENTRY_PATH" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
if [[ $ENTRY_DIR = */* ]]; then
|
||||
echo "$0: ERROR: dir from arg: $ENTRY_PATH contains a /: $ENTRY_DIR" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -d $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY from arg: $ENTRY_PATH is not a directory: $YEAR_DIR" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
export ENTRY_ID="${YEAR_DIR}_${ENTRY_DIR}"
|
||||
export DOT_YEAR="$YEAR_DIR/.year"
|
||||
if [[ ! -e $DOT_YEAR ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .year does not exist: $DOT_YEAR" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -f $DOT_YEAR ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .year is not a file: $DOT_YEAR" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -r $DOT_YEAR ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .year is not a readable file: $DOT_YEAR" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -s $DOT_YEAR ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .year is not a non-empty readable file: $DOT_YEAR" 1>&2
|
||||
exit 7
|
||||
echo "$0: ERROR: not a non-empty file: $DOT_YEAR" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
# Now that we have moved to topdir, form and verify YYYY_DIR is a writable directory
|
||||
export YYYY_DIR="$YEAR_DIR/$ENTRY_DIR"
|
||||
@@ -397,26 +358,42 @@ if [[ ! -w $YYYY_DIR ]]; then
|
||||
exit 7
|
||||
fi
|
||||
export DOT_PATH="$YYYY_DIR/.path"
|
||||
if [[ ! -e $DOT_PATH ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .path does not exist: $DOT_PATH" 1>&2
|
||||
exit 8
|
||||
fi
|
||||
if [[ ! -f $DOT_PATH ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .path is not a file: $DOT_PATH" 1>&2
|
||||
exit 8
|
||||
fi
|
||||
if [[ ! -r $DOT_PATH ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .path is not a readable file: $DOT_PATH" 1>&2
|
||||
exit 8
|
||||
fi
|
||||
if [[ ! -s $DOT_PATH ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .path is not a non-empty readable file: $DOT_PATH" 1>&2
|
||||
exit 8
|
||||
echo "$0: ERROR: not a non-empty file: $DOT_PATH" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
DOT_PATH_CONTENT=$(< "$DOT_PATH")
|
||||
if [[ $ENTRY_PATH != "$DOT_PATH_CONTENT" ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .path: $DOT_PATH contents: $DOT_PATH_CONTENT" 1>&2
|
||||
exit 8
|
||||
echo "$0: ERROR: arg: $ENTRY_PATH does not match $DOT_PATH contents: $DOT_PATH_CONTENT" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
export ENTRY_JSON="$YYYY_DIR/.entry.json"
|
||||
if [[ ! -e $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json does not exist: $ENTRY_JSON" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -f $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a file: $ENTRY_JSON" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -r $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a readable file: $ENTRY_JSON" 1>&2
|
||||
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,19 +402,19 @@ export README_PATH="$YYYY_DIR/README.md"
|
||||
export INDEX_PATH="$YYYY_DIR/index.html"
|
||||
if [[ ! -e $README_PATH ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH README.md does not exist: $README_PATH" 1>&2
|
||||
exit 8
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -f $README_PATH ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH README.md is not a file: $README_PATH" 1>&2
|
||||
exit 8
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -r $README_PATH ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH README.md is not a readable file: $README_PATH" 1>&2
|
||||
exit 8
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -s $README_PATH ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH README.md is not a non-empty readable file: $README_PATH" 1>&2
|
||||
exit 8
|
||||
exit 7
|
||||
fi
|
||||
|
||||
# verify that .entry.json is a non-empty readable file
|
||||
@@ -445,19 +422,19 @@ fi
|
||||
export ENTRY_JSON="$YYYY_DIR/.entry.json"
|
||||
if [[ ! -e $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .entry.json does not exist: $ENTRY_JSON" 1>&2
|
||||
exit 8
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -f $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .entry.json is not a file: $ENTRY_JSON" 1>&2
|
||||
exit 8
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -r $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .entry.json is not a readable file: $ENTRY_JSON" 1>&2
|
||||
exit 8
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -s $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .entry.json is not a non-empty readable file: $ENTRY_JSON" 1>&2
|
||||
exit 8
|
||||
exit 7
|
||||
fi
|
||||
|
||||
# always add the '-U URL' for the entry's index.html file
|
||||
|
||||
+93
-97
@@ -52,7 +52,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.2 2024-02-11"
|
||||
export VERSION="1.2.1 2024-02-23"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -60,7 +60,7 @@ GIT_TOOL=$(type -P git)
|
||||
export GIT_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: git tool is not installed or not in \$PATH" 1>&2
|
||||
exit 10
|
||||
exit 5
|
||||
fi
|
||||
"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
status="$?"
|
||||
@@ -127,17 +127,14 @@ NOTE: The '-v level' is passed as initial command line options to the 'markdown
|
||||
|
||||
Exit codes:
|
||||
0 all OK
|
||||
1 md2html.sh exited non-zero
|
||||
1 some internal tool exited non-zero
|
||||
2 -h and help string printed or -V and version string printed
|
||||
3 command line error
|
||||
4 bash version is < 4.2
|
||||
5 md2html.sh is not an executable file
|
||||
XXX - update this - XXX
|
||||
6 problems found with or in the topdir directory
|
||||
7 problems found with or in the topdir/YYYY directory
|
||||
8 problems found with or in the topdir/YYYY/dir directory
|
||||
>= 10 < 200 internal error
|
||||
>= 200 ((not used))
|
||||
5 some internal tool is not found or not an executable file
|
||||
6 problems found with or in the topdir or topdir/YYYY directory
|
||||
7 problems found with or in the entry topdir/YYYY/dir directory
|
||||
>= 10 internal error
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
@@ -262,58 +259,6 @@ if [[ -n $TAGLINE ]]; then
|
||||
TOOL_OPTION+=("$TAGLINE")
|
||||
fi
|
||||
|
||||
# parse the ENTRY_PATH arg
|
||||
#
|
||||
# verify that ENTRY_PATH is in proper form
|
||||
#
|
||||
# Also obtain the YEAR_DIR and ENTRY_DIR from ENTRY_PATH.
|
||||
#
|
||||
if [[ -z $ENTRY_PATH ]]; then
|
||||
echo "$0: ERROR: arg is an empty string" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -d $ENTRY_PATH ]]; then
|
||||
echo "$0: ERROR: arg is not a directory: $ENTRY_PATH" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -w $ENTRY_PATH ]]; then
|
||||
echo "$0: ERROR: arg is not a writable directory: $ENTRY_PATH" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
export YEAR_DIR=${ENTRY_PATH%%/*}
|
||||
if [[ -z $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: arg not in YYYY/dir form: $ENTRY_PATH" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -d $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY from arg: $ENTRY_PATH is not a directory: $YEAR_DIR" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
export ENTRY_DIR=${ENTRY_PATH#*/}
|
||||
if [[ -z $ENTRY_DIR ]]; then
|
||||
echo "$0: ERROR: arg: $ENTRY_PATH not in $YEAR_DIR/dir form: $ENTRY_PATH" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
if [[ $ENTRY_DIR = */* ]]; then
|
||||
echo "$0: ERROR: dir from arg: $ENTRY_PATH contains a /: $ENTRY_DIR" 1>&2
|
||||
exit 3
|
||||
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
|
||||
|
||||
# verify that we have a topdir directory
|
||||
#
|
||||
REPO_NAME=$(basename "$REPO_URL")
|
||||
@@ -357,24 +302,39 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
# perform tests on YYYY_DIR (YYYY/dir) as a entry directory
|
||||
# verify that ENTRY_PATH is a entry directory
|
||||
#
|
||||
if [[ ! -d $ENTRY_PATH ]]; then
|
||||
echo "$0: ERROR: arg is not a directory: $ENTRY_PATH" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -w $ENTRY_PATH ]]; then
|
||||
echo "$0: ERROR: arg is not a writable directory: $ENTRY_PATH" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
export YEAR_DIR=${ENTRY_PATH%%/*}
|
||||
if [[ -z $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: arg not in YYYY/dir form: $ENTRY_PATH" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
export ENTRY_DIR=${ENTRY_PATH#*/}
|
||||
if [[ -z $ENTRY_DIR ]]; then
|
||||
echo "$0: ERROR: arg: $ENTRY_PATH not in $YEAR_DIR/dir form: $ENTRY_PATH" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
if [[ $ENTRY_DIR = */* ]]; then
|
||||
echo "$0: ERROR: dir from arg: $ENTRY_PATH contains a /: $ENTRY_DIR" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -d $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY from arg: $ENTRY_PATH is not a directory: $YEAR_DIR" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
export ENTRY_ID="${YEAR_DIR}_${ENTRY_DIR}"
|
||||
export DOT_YEAR="$YEAR_DIR/.year"
|
||||
if [[ ! -e $DOT_YEAR ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .year does not exist: $DOT_YEAR" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -f $DOT_YEAR ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .year is not a file: $DOT_YEAR" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -r $DOT_YEAR ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .year is not a readable file: $DOT_YEAR" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -s $DOT_YEAR ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .year is not a non-empty readable file: $DOT_YEAR" 1>&2
|
||||
exit 7
|
||||
echo "$0: ERROR: not a non-empty file: $DOT_YEAR" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
# Now that we have moved to topdir, form and verify YYYY_DIR is a writable directory
|
||||
export YYYY_DIR="$YEAR_DIR/$ENTRY_DIR"
|
||||
@@ -391,26 +351,42 @@ if [[ ! -w $YYYY_DIR ]]; then
|
||||
exit 7
|
||||
fi
|
||||
export DOT_PATH="$YYYY_DIR/.path"
|
||||
if [[ ! -e $DOT_PATH ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .path does not exist: $DOT_PATH" 1>&2
|
||||
exit 8
|
||||
fi
|
||||
if [[ ! -f $DOT_PATH ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .path is not a file: $DOT_PATH" 1>&2
|
||||
exit 8
|
||||
fi
|
||||
if [[ ! -r $DOT_PATH ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .path is not a readable file: $DOT_PATH" 1>&2
|
||||
exit 8
|
||||
fi
|
||||
if [[ ! -s $DOT_PATH ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .path is not a non-empty readable file: $DOT_PATH" 1>&2
|
||||
exit 8
|
||||
echo "$0: ERROR: not a non-empty file: $DOT_PATH" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
DOT_PATH_CONTENT=$(< "$DOT_PATH")
|
||||
if [[ $ENTRY_PATH != "$DOT_PATH_CONTENT" ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .path: $DOT_PATH contents: $DOT_PATH_CONTENT" 1>&2
|
||||
exit 8
|
||||
echo "$0: ERROR: arg: $ENTRY_PATH does not match $DOT_PATH contents: $DOT_PATH_CONTENT" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
export ENTRY_JSON="$YYYY_DIR/.entry.json"
|
||||
if [[ ! -e $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json does not exist: $ENTRY_JSON" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -f $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a file: $ENTRY_JSON" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -r $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a readable file: $ENTRY_JSON" 1>&2
|
||||
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
|
||||
@@ -419,19 +395,39 @@ export README_PATH="$YYYY_DIR/README.md"
|
||||
export INDEX_PATH="$YYYY_DIR/index.html"
|
||||
if [[ ! -e $README_PATH ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH README.md does not exist: $README_PATH" 1>&2
|
||||
exit 8
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -f $README_PATH ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH README.md is not a file: $README_PATH" 1>&2
|
||||
exit 8
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -r $README_PATH ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH README.md is not a readable file: $README_PATH" 1>&2
|
||||
exit 8
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -s $README_PATH ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH README.md is not a non-empty readable file: $README_PATH" 1>&2
|
||||
exit 8
|
||||
exit 7
|
||||
fi
|
||||
|
||||
# verify that .entry.json is a non-empty readable file
|
||||
#
|
||||
export ENTRY_JSON="$YYYY_DIR/.entry.json"
|
||||
if [[ ! -e $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .entry.json does not exist: $ENTRY_JSON" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -f $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .entry.json is not a file: $ENTRY_JSON" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -r $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .entry.json is not a readable file: $ENTRY_JSON" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -s $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: in $ENTRY_PATH .entry.json is not a non-empty readable file: $ENTRY_JSON" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
|
||||
# always add the '-U URL' for the entry's index.html file
|
||||
|
||||
+70
-52
@@ -64,7 +64,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 2024-02-11"
|
||||
export VERSION="1.1.1 2024-02-23"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -72,7 +72,7 @@ GIT_TOOL=$(type -P git)
|
||||
export GIT_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: git tool is not installed or not in PATH" 1>&2
|
||||
exit 200
|
||||
exit 5
|
||||
fi
|
||||
"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
status="$?"
|
||||
@@ -102,13 +102,14 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N]
|
||||
|
||||
Exit codes:
|
||||
0 all OK
|
||||
1 sgi.sh exited non-zero
|
||||
1 some internal tool exited non-zero
|
||||
2 -h and help string printed or -V and version string printed
|
||||
3 command line error
|
||||
4 bash version is < 4.2
|
||||
5 YYYY/dir is not a entry directory
|
||||
6 sgi.sh tool not found or not executable
|
||||
>= 10 internal error
|
||||
5 some internal tool is not found or not an executable file
|
||||
6 problems found with or in the topdir or topdir/YYYY directory
|
||||
7 problems found with or in the entry topdir/YYYY/dir directory
|
||||
>= 10 internal error
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
@@ -181,32 +182,23 @@ export REPO_NAME
|
||||
if [[ -z $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot find top of git repo directory" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 201
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR is not a directory: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 202
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify that we have an 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 205
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to non-existent path: $TOPDIR" 1>&2
|
||||
exit 206
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to a non-directory: $TOPDIR" 1>&2
|
||||
exit 207
|
||||
exit 6
|
||||
fi
|
||||
export CD_FAILED
|
||||
if [[ $V_FLAG -ge 5 ]]; then
|
||||
@@ -215,96 +207,122 @@ fi
|
||||
cd "$TOPDIR" || CD_FAILED="true"
|
||||
if [[ -n $CD_FAILED ]]; then
|
||||
echo "$0: ERROR: cd $TOPDIR failed" 1>&2
|
||||
exit 208
|
||||
exit 6
|
||||
fi
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
# verify that we have an 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 an executable sgi.sh tool
|
||||
#
|
||||
if [[ ! -e $SGI_TOOL ]]; then
|
||||
echo "$0: ERROR: sgi.sh tool does not exist: $SGI_TOOL" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -f $SGI_TOOL ]]; then
|
||||
echo "$0: ERROR: sgi.sh tool is not a file: $SGI_TOOL" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
if [[ ! -x $SGI_TOOL ]]; then
|
||||
echo "$0: ERROR: sgi.sh tool is not an executable file: $SGI_TOOL" 1>&2
|
||||
exit 6
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# verify that ENTRY_PATH is a entry directory
|
||||
#
|
||||
# ENTRY_PATH must be in YYYY/dir form
|
||||
# YYYY must be a directory
|
||||
# YYYY must be a writable directory
|
||||
# YYYY/.year must be a non-empty file
|
||||
# YYYY/dir must be a directory
|
||||
# YYYY/dir/.path must be a non-empty file
|
||||
# ENTRY_PATH must match the contents of YYYY/dir/.path
|
||||
# YYYY/dir/.gitignore.json must be a writable file
|
||||
#
|
||||
if [[ ! -d $ENTRY_PATH ]]; then
|
||||
echo "$0: ERROR: arg is not a directory: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -w $ENTRY_PATH ]]; then
|
||||
echo "$0: ERROR: arg is not a writable directory: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
export YEAR_DIR=${ENTRY_PATH%%/*}
|
||||
if [[ -z $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: arg not in YYYY/dir form: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
export ENTRY_DIR=${ENTRY_PATH#*/}
|
||||
if [[ -z $ENTRY_DIR ]]; then
|
||||
echo "$0: ERROR: arg: $ENTRY_PATH not in $YEAR_DIR/dir form: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
if [[ $ENTRY_DIR = */* ]]; then
|
||||
echo "$0: ERROR: dir from arg: $ENTRY_PATH contains a /: $ENTRY_DIR" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -d $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY from arg: $ENTRY_PATH is not a directory: $YEAR_DIR" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
export ENTRY_ID="${YEAR_DIR}_${ENTRY_DIR}"
|
||||
export DOT_YEAR="$YEAR_DIR/.year"
|
||||
if [[ ! -s $DOT_YEAR ]]; then
|
||||
echo "$0: ERROR: not a non-empty file: $DOT_YEAR" 1>&2
|
||||
exit 5
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $YEAR_DIR/$ENTRY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY/dir from arg: $ENTRY_PATH is not a directory: $YEAR_DIR/$ENTRY_DIR" 1>&2
|
||||
exit 5
|
||||
# Now that we have moved to topdir, form and verify YYYY_DIR is a writable directory
|
||||
export YYYY_DIR="$YEAR_DIR/$ENTRY_DIR"
|
||||
if [[ ! -e $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY/dir from arg: $ENTRY_PATH does not exist: $YYYY_DIR" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
export DOT_PATH="$YEAR_DIR/$ENTRY_DIR/.path"
|
||||
if [[ ! -d $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY/dir from arg: $ENTRY_PATH is not a directory: $YYYY_DIR" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -w $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY/dir from arg: $ENTRY_PATH is not a writable directory: $YYYY_DIR" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
export DOT_PATH="$YYYY_DIR/.path"
|
||||
if [[ ! -s $DOT_PATH ]]; then
|
||||
echo "$0: ERROR: not a non-empty file: $DOT_PATH" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
DOT_PATH_CONTENT=$(< "$DOT_PATH")
|
||||
if [[ $ENTRY_PATH != "$DOT_PATH_CONTENT" ]]; then
|
||||
echo "$0: ERROR: arg: $ENTRY_PATH does not match $DOT_PATH contents: $DOT_PATH_CONTENT" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
export ENTRY_JSON="$YYYY_DIR/.entry.json"
|
||||
if [[ ! -e $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json does not exist: $ENTRY_JSON" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -f $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a file: $ENTRY_JSON" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -r $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a readable file: $ENTRY_JSON" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
|
||||
# verify .gitignore
|
||||
#
|
||||
export GITIGNORE="$YEAR_DIR/$ENTRY_DIR/.gitignore"
|
||||
if [[ ! -e $GITIGNORE ]]; then
|
||||
echo "$0: ERROR: .entry.json does not exist: $GITIGNORE" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -f $GITIGNORE ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a file: $GITIGNORE" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -w $GITIGNORE ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a writable file: $GITIGNORE" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
|
||||
# parameter debugging
|
||||
@@ -352,12 +370,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_FILE"
|
||||
if [[ -e $TMP_FILE ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary markdown file: $TMP_FILE" 1>&2
|
||||
exit 216
|
||||
exit 10
|
||||
fi
|
||||
:> "$TMP_FILE"
|
||||
if [[ ! -e $TMP_FILE ]]; then
|
||||
echo "$0: ERROR: cannot create temporary markdown file: $TMP_FILE" 1>&2
|
||||
exit 217
|
||||
exit 11
|
||||
fi
|
||||
elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary markdown file is not used: $TMP_FILE" 1>&2
|
||||
@@ -373,7 +391,7 @@ if [[ -z $NOOP ]]; then
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: sgi.sh failed, error: $status" 1>&2
|
||||
exit 220
|
||||
exit 12
|
||||
fi
|
||||
if [[ $V_FLAG -ge 1 ]]; then
|
||||
echo "$0: debug[1]: about to execute: mv -f $TMP_FILE $GITIGNORE" 1>&2
|
||||
@@ -382,7 +400,7 @@ if [[ -z $NOOP ]]; then
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: sgi.sh failed, error: $status" 1>&2
|
||||
exit 220
|
||||
exit 13
|
||||
fi
|
||||
elif [[ $V_FLAG -ge 1 ]]; then
|
||||
echo "$0: debug[1]: -n disabled execution of: $SGI_TOOL < $GITIGNORE > $TMP_FILE" 1>&2
|
||||
|
||||
@@ -58,7 +58,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.2 2024-02-05"
|
||||
export VERSION="1.2.1 2024-02-23"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -66,7 +66,7 @@ GIT_TOOL=$(type -P git)
|
||||
export GIT_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: git tool is not installed or not in \$PATH" 1>&2
|
||||
exit 210
|
||||
exit 5
|
||||
fi
|
||||
"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
status="$?"
|
||||
@@ -107,12 +107,12 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
|
||||
Exit codes:
|
||||
0 all OK
|
||||
1 pandoc exited non-zero
|
||||
1 some internal tool exited non-zero
|
||||
2 -h and help string printed or -V and version string printed
|
||||
3 command line error
|
||||
4 bash version is < 4.2
|
||||
>= 10 < 210 ((not used))
|
||||
>= 210 internal tool error
|
||||
5 some internal tool is not found or not an executable file
|
||||
>= 10 internal error
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
|
||||
+60
-70
@@ -58,7 +58,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.2 2024-02-11"
|
||||
export VERSION="1.2.1 2024-02-23"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -66,7 +66,7 @@ GIT_TOOL=$(type -P git)
|
||||
export GIT_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: git tool is not installed or not in \$PATH" 1>&2
|
||||
exit 210
|
||||
exit 5
|
||||
fi
|
||||
"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
status="$?"
|
||||
@@ -106,15 +106,14 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N]
|
||||
|
||||
Exit codes:
|
||||
0 all OK
|
||||
1 pandoc exited non-zero
|
||||
1 some internal tool exited non-zero
|
||||
2 -h and help string printed or -V and version string printed
|
||||
3 command line error
|
||||
4 bash version is < 4.2
|
||||
5 YYYY/dir is not a entry directory
|
||||
6 subst.entry-navbar.awk tool not found
|
||||
7 cannot find important information about the author or winning entry
|
||||
>= 10 < 210 ((not used))
|
||||
>= 210 internal tool error
|
||||
5 some internal tool is not found or not an executable file
|
||||
6 problems found with or in the topdir or topdir/YYYY directory
|
||||
7 problems found with or in the entry topdir/YYYY/dir directory
|
||||
>= 10 internal error
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
@@ -258,55 +257,28 @@ export REPO_NAME
|
||||
if [[ -z $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot find top of git repo directory" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 211
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR does not exist: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 212
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR is not a directory: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 213
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify that we have an author subdirectory
|
||||
#
|
||||
export AUTHOR_PATH="$TOPDIR/author"
|
||||
if [[ ! -d $AUTHOR_PATH ]]; then
|
||||
echo "$0: ERROR: author is not a directory under topdir: $AUTHOR_PATH" 1>&2
|
||||
exit 214
|
||||
fi
|
||||
export AUTHOR_DIR="author"
|
||||
|
||||
# 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 215
|
||||
fi
|
||||
export INC_DIR="inc"
|
||||
|
||||
# verify that we have an 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 216
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to non-existent path: $TOPDIR" 1>&2
|
||||
exit 217
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to a non-directory: $TOPDIR" 1>&2
|
||||
exit 218
|
||||
exit 6
|
||||
fi
|
||||
export CD_FAILED
|
||||
if [[ $V_FLAG -ge 5 ]]; then
|
||||
@@ -315,91 +287,109 @@ fi
|
||||
cd "$TOPDIR" || CD_FAILED="true"
|
||||
if [[ -n $CD_FAILED ]]; then
|
||||
echo "$0: ERROR: cd $TOPDIR failed" 1>&2
|
||||
exit 219
|
||||
exit 6
|
||||
fi
|
||||
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
|
||||
# verify that we have an author subdirectory
|
||||
#
|
||||
# ENTRY_PATH must be in YYYY/dir form
|
||||
# YYYY must be a directory
|
||||
# YYYY must be a writable directory
|
||||
# YYYY/.year must be a non-empty file
|
||||
# YYYY/dir must be a directory
|
||||
# YYYY/dir/.path must be a non-empty file
|
||||
# ENTRY_PATH must match the contents of YYYY/dir/.path
|
||||
# YYYY/dir/.entry.json must be a non-empty file
|
||||
export AUTHOR_PATH="$TOPDIR/author"
|
||||
if [[ ! -d $AUTHOR_PATH ]]; then
|
||||
echo "$0: ERROR: author is not a directory under topdir: $AUTHOR_PATH" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
export AUTHOR_DIR="author"
|
||||
|
||||
# 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 an 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
|
||||
#
|
||||
if [[ ! -d $ENTRY_PATH ]]; then
|
||||
echo "$0: ERROR: arg is not a directory: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -w $ENTRY_PATH ]]; then
|
||||
echo "$0: ERROR: arg is not a writable directory: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
export YEAR_DIR=${ENTRY_PATH%%/*}
|
||||
if [[ -z $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: arg not in YYYY/dir form: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
export ENTRY_DIR=${ENTRY_PATH#*/}
|
||||
if [[ -z $ENTRY_DIR ]]; then
|
||||
echo "$0: ERROR: arg: $ENTRY_PATH not in $YEAR_DIR/dir form: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
if [[ $ENTRY_DIR = */* ]]; then
|
||||
echo "$0: ERROR: dir from arg: $ENTRY_PATH contains a /: $ENTRY_DIR" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -d $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY from arg: $ENTRY_PATH is not a directory: $YEAR_DIR" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
export ENTRY_ID="${YEAR_DIR}_${ENTRY_DIR}"
|
||||
export DOT_YEAR="$YEAR_DIR/.year"
|
||||
if [[ ! -s $DOT_YEAR ]]; then
|
||||
echo "$0: ERROR: not a non-empty file: $DOT_YEAR" 1>&2
|
||||
exit 5
|
||||
exit 6
|
||||
fi
|
||||
# Now that we have moved to topdir, form and verify YYYY_DIR is a writable directory
|
||||
export YYYY_DIR="$YEAR_DIR/$ENTRY_DIR"
|
||||
if [[ ! -e $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY/dir from arg: $ENTRY_PATH does not exist: $YYYY_DIR" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -d $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY/dir from arg: $ENTRY_PATH is not a directory: $YYYY_DIR" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -w $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY/dir from arg: $ENTRY_PATH is not a writable directory: $YYYY_DIR" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
export DOT_PATH="$YYYY_DIR/.path"
|
||||
if [[ ! -s $DOT_PATH ]]; then
|
||||
echo "$0: ERROR: not a non-empty file: $DOT_PATH" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
DOT_PATH_CONTENT=$(< "$DOT_PATH")
|
||||
if [[ $ENTRY_PATH != "$DOT_PATH_CONTENT" ]]; then
|
||||
echo "$0: ERROR: arg: $ENTRY_PATH does not match $DOT_PATH contents: $DOT_PATH_CONTENT" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
export ENTRY_JSON="$YYYY_DIR/.entry.json"
|
||||
if [[ ! -e $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json does not exist: $ENTRY_JSON" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -f $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a file: $ENTRY_JSON" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -r $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a readable file: $ENTRY_JSON" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
|
||||
# verify we have our awk script
|
||||
@@ -407,15 +397,15 @@ fi
|
||||
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 6
|
||||
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 6
|
||||
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 6
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# determine award
|
||||
@@ -423,7 +413,7 @@ fi
|
||||
AWARD=$(output_award "$ENTRY_JSON")
|
||||
if [[ -z $AWARD ]]; then
|
||||
echo "$0: ERROR: cannot determine award for $YEAR_DIR from: $ENTRY_JSON" 1>&2
|
||||
exit 7
|
||||
exit 1
|
||||
fi
|
||||
export AWARD
|
||||
|
||||
@@ -493,7 +483,7 @@ awk -v entry_path="$YYYY_DIR" -f "$ENTRY_NAVBAR_AWK" "$DOT_YEAR"
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: subst.entry-navbar.awk failed, error: $status" 1>&2
|
||||
exit 219
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# All Done!!! -- Jessica Noll, Age 2
|
||||
|
||||
+27
-37
@@ -58,7 +58,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.0 2024-02-11"
|
||||
export VERSION="1.0.1 2024-02-23"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -66,7 +66,7 @@ GIT_TOOL=$(type -P git)
|
||||
export GIT_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: git tool is not installed or not in \$PATH" 1>&2
|
||||
exit 210
|
||||
exit 5
|
||||
fi
|
||||
"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
status="$?"
|
||||
@@ -106,15 +106,14 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N]
|
||||
|
||||
Exit codes:
|
||||
0 all OK
|
||||
1 pandoc exited non-zero
|
||||
1 some internal tool exited non-zero
|
||||
2 -h and help string printed or -V and version string printed
|
||||
3 command line error
|
||||
4 bash version is < 4.2
|
||||
5 YYYY is not a year directory
|
||||
6 subst.year-navbar.awk tool not found
|
||||
7 cannot find important information about the author or winning entry
|
||||
>= 10 < 210 ((not used))
|
||||
>= 210 internal tool error
|
||||
5 some internal tool is not found or not an executable file
|
||||
6 problems found with or in the topdir or topdir/YYYY directory
|
||||
7 problems found with or in the entry topdir/YYYY/dir directory
|
||||
>= 10 internal error
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
@@ -269,17 +268,17 @@ export REPO_NAME
|
||||
if [[ -z $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot find top of git repo directory" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 211
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR does not exist: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 212
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR is not a directory: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 213
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify that we have an author subdirectory
|
||||
@@ -287,7 +286,7 @@ fi
|
||||
export AUTHOR_PATH="$TOPDIR/author"
|
||||
if [[ ! -d $AUTHOR_PATH ]]; then
|
||||
echo "$0: ERROR: author is not a directory under topdir: $AUTHOR_PATH" 1>&2
|
||||
exit 214
|
||||
exit 6
|
||||
fi
|
||||
export AUTHOR_DIR="author"
|
||||
|
||||
@@ -296,7 +295,7 @@ export AUTHOR_DIR="author"
|
||||
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 215
|
||||
exit 6
|
||||
fi
|
||||
export INC_DIR="inc"
|
||||
|
||||
@@ -305,7 +304,7 @@ export INC_DIR="inc"
|
||||
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 216
|
||||
exit 6
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
@@ -313,11 +312,11 @@ export BIN_DIR="bin"
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to non-existent path: $TOPDIR" 1>&2
|
||||
exit 217
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to a non-directory: $TOPDIR" 1>&2
|
||||
exit 218
|
||||
exit 6
|
||||
fi
|
||||
export CD_FAILED
|
||||
if [[ $V_FLAG -ge 5 ]]; then
|
||||
@@ -326,7 +325,7 @@ fi
|
||||
cd "$TOPDIR" || CD_FAILED="true"
|
||||
if [[ -n $CD_FAILED ]]; then
|
||||
echo "$0: ERROR: cd $TOPDIR failed" 1>&2
|
||||
exit 219
|
||||
exit 6
|
||||
fi
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
@@ -334,27 +333,18 @@ fi
|
||||
|
||||
# verify that YEAR_ARG is a entry directory
|
||||
#
|
||||
# YEAR_ARG must be in YYYY/dir form
|
||||
# YYYY must be a directory
|
||||
# YYYY must be a writable directory
|
||||
# YYYY/.year must be a non-empty file
|
||||
# YYYY/dir must be a directory
|
||||
# YYYY/dir/.path must be a non-empty file
|
||||
# YEAR_ARG must match the contents of YYYY/dir/.path
|
||||
# YYYY/dir/.entry.json must be a non-empty file
|
||||
#
|
||||
if [[ ! -d $YEAR_ARG ]]; then
|
||||
echo "$0: ERROR: arg is not a directory: $YEAR_ARG" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -w $YEAR_ARG ]]; then
|
||||
echo "$0: ERROR: arg is not a writable directory: $YEAR_ARG" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
export YEAR_DIR=${YEAR_ARG%%/*}
|
||||
if [[ -z $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: arg not in YYYY/dir form: $YEAR_ARG" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# verify we have a non-empty readable .top file
|
||||
@@ -382,15 +372,15 @@ fi
|
||||
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 6
|
||||
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 6
|
||||
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 6
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# determine The N-th IOCCC string
|
||||
@@ -401,8 +391,8 @@ if [[ -z $LINE_NUM ]]; then
|
||||
echo '-e'
|
||||
echo "cannot determine line number in $TOP_FILE for year: $YEAR_DIR"
|
||||
echo '-E'
|
||||
echo 220
|
||||
exit 220
|
||||
echo 210
|
||||
exit 210
|
||||
fi
|
||||
ORDINAL=$(output_ordinal "$LINE_NUM")
|
||||
export ORDINAL
|
||||
@@ -410,8 +400,8 @@ if [[ -z $ORDINAL ]]; then
|
||||
echo '-e'
|
||||
echo "cannot determine ordinal for: $LINE_NUM"
|
||||
echo '-E'
|
||||
echo 221
|
||||
exit 221
|
||||
echo 211
|
||||
exit 211
|
||||
fi
|
||||
|
||||
# parameter debugging
|
||||
@@ -476,7 +466,7 @@ awk -v year_arg="$YEAR_DIR" -f "$YEAR_NAVBAR_AWK" "$TOP_FILE"
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: subst.year-navbar.awk failed, error: $status" 1>&2
|
||||
exit 219
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# All Done!!! -- Jessica Noll, Age 2
|
||||
|
||||
+82
-84
@@ -49,7 +49,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.0 2024-02-17"
|
||||
export VERSION="1.0.1 2024-02-23"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -57,7 +57,7 @@ GIT_TOOL=$(type -P git)
|
||||
export GIT_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: git tool is not installed or not in \$PATH" 1>&2
|
||||
exit 210
|
||||
exit 5
|
||||
fi
|
||||
"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
status="$?"
|
||||
@@ -71,7 +71,7 @@ GTAR_TOOL=$(type -P gtar)
|
||||
export GTAR_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: gtar (gnu tar) tool is not installed or not in \$PATH" 1>&2
|
||||
exit 9
|
||||
exit 8
|
||||
fi
|
||||
|
||||
# set usage message
|
||||
@@ -98,17 +98,15 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
|
||||
Exit codes:
|
||||
0 all OK
|
||||
1 a file listed in .entry.json or .filelist is missing and -W was not used, or no files were found
|
||||
1 some internal tool exited non-zero
|
||||
2 -h and help string printed or -V and version string printed
|
||||
3 command line error
|
||||
4 bash version is < 4.2
|
||||
5 YYYY/dir is not a entry directory, or YYYY is not an IOCCC year
|
||||
6 bin/filelist.entry.json.awk is not a non-empty readable file
|
||||
7 error in trying to determine files used by the year
|
||||
8 missing critical top level file or missing .filelist file
|
||||
9 gnu tar is missing or execution failed
|
||||
>= 10 < 210 ((not used))
|
||||
>= 210 internal tool error
|
||||
5 some internal tool is not found or not an executable file
|
||||
6 problems found with or in the topdir or topdir/YYYY directory
|
||||
7 problems found with or in the entry topdir/YYYY/dir directory
|
||||
8 gnu tar is missing or execution failed or error in forming compressed tarball
|
||||
>= 10 internal error
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
@@ -185,37 +183,28 @@ export REPO_NAME
|
||||
if [[ -z $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot find top of git repo directory" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 220
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR does not exist: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 221
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR is not a directory: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 222
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify that we have an 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 223
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to non-existent path: $TOPDIR" 1>&2
|
||||
exit 224
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to a non-directory: $TOPDIR" 1>&2
|
||||
exit 225
|
||||
exit 6
|
||||
fi
|
||||
export CD_FAILED
|
||||
if [[ $V_FLAG -ge 5 ]]; then
|
||||
@@ -224,12 +213,21 @@ fi
|
||||
cd "$TOPDIR" || CD_FAILED="true"
|
||||
if [[ -n $CD_FAILED ]]; then
|
||||
echo "$0: ERROR: cd $TOPDIR failed" 1>&2
|
||||
exit 226
|
||||
exit 6
|
||||
fi
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
# verify that we have an 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"
|
||||
|
||||
# determine the name of our tarball
|
||||
#
|
||||
export TARBALL="ioccc.tar.bz2"
|
||||
@@ -239,19 +237,19 @@ export TARBALL="ioccc.tar.bz2"
|
||||
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 6
|
||||
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 6
|
||||
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 6
|
||||
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 6
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# verify we have non-empty readable ioccc.css file
|
||||
@@ -259,19 +257,19 @@ fi
|
||||
export IOCCC_CSS="ioccc.css"
|
||||
if [[ ! -e $IOCCC_CSS ]]; then
|
||||
echo "$0: ERROR: ioccc.css does not exist: $IOCCC_CSS" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -f $IOCCC_CSS ]]; then
|
||||
echo "$0: ERROR: ioccc.css is not a file: $IOCCC_CSS" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -r $IOCCC_CSS ]]; then
|
||||
echo "$0: ERROR: ioccc.css is not a readable file: $IOCCC_CSS" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -s $IOCCC_CSS ]]; then
|
||||
echo "$0: ERROR: ioccc.css is not a not a non-empty readable file: $IOCCC_CSS" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify we have non-empty readable ioccc.css file
|
||||
@@ -279,19 +277,19 @@ fi
|
||||
export VAR_MK="var.mk"
|
||||
if [[ ! -e $VAR_MK ]]; then
|
||||
echo "$0: ERROR: var.mk does not exist: $VAR_MK" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -f $VAR_MK ]]; then
|
||||
echo "$0: ERROR: var.mk is not a file: $VAR_MK" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -r $VAR_MK ]]; then
|
||||
echo "$0: ERROR: var.mk is not a readable file: $VAR_MK" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -s $VAR_MK ]]; then
|
||||
echo "$0: ERROR: var.mk is not a not a non-empty readable file: $VAR_MK" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify we have a non-empty readable .top file
|
||||
@@ -299,19 +297,19 @@ fi
|
||||
export TOP_FILE=".top"
|
||||
if [[ ! -e $TOP_FILE ]]; then
|
||||
echo "$0: ERROR: .top does not exist: $TOP_FILE" 1>&2
|
||||
exit 5
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -f $TOP_FILE ]]; then
|
||||
echo "$0: ERROR: .top is not a regular file: $TOP_FILE" 1>&2
|
||||
exit 5
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -r $TOP_FILE ]]; then
|
||||
echo "$0: ERROR: .top is not an readable file: $TOP_FILE" 1>&2
|
||||
exit 5
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -s $TOP_FILE ]]; then
|
||||
echo "$0: ERROR: .top is not a non-empty readable file: $TOP_FILE" 1>&2
|
||||
exit 5
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# parameter debugging
|
||||
@@ -359,12 +357,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_MANIFEST_LIST"
|
||||
if [[ -e $TMP_MANIFEST_LIST ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary file manifest list: $TMP_MANIFEST_LIST" 1>&2
|
||||
exit 227
|
||||
exit 10
|
||||
fi
|
||||
:> "$TMP_MANIFEST_LIST"
|
||||
if [[ ! -e $TMP_MANIFEST_LIST ]]; then
|
||||
echo "$0: ERROR: cannot create temporary file manifest list: $TMP_MANIFEST_LIST" 1>&2
|
||||
exit 228
|
||||
exit 11
|
||||
fi
|
||||
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
|
||||
@@ -381,12 +379,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_TAR_LIST"
|
||||
if [[ -e $TMP_TAR_LIST ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary file tar list: $TMP_TAR_LIST" 1>&2
|
||||
exit 231
|
||||
exit 12
|
||||
fi
|
||||
:> "$TMP_TAR_LIST"
|
||||
if [[ ! -e $TMP_TAR_LIST ]]; then
|
||||
echo "$0: ERROR: cannot create temporary file tar list: $TMP_TAR_LIST" 1>&2
|
||||
exit 232
|
||||
exit 13
|
||||
fi
|
||||
elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary file tar list is not used: $TMP_TAR_LIST" 1>&2
|
||||
@@ -406,12 +404,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_EXIT_CODE"
|
||||
if [[ -e $TMP_EXIT_CODE ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary exit code: $TMP_EXIT_CODE" 1>&2
|
||||
exit 233
|
||||
exit 14
|
||||
fi
|
||||
echo "$EXIT_CODE" > "$TMP_EXIT_CODE"
|
||||
if [[ ! -e $TMP_EXIT_CODE ]]; then
|
||||
echo "$0: ERROR: cannot create temporary exit code: $TMP_EXIT_CODE" 1>&2
|
||||
exit 234
|
||||
exit 15
|
||||
fi
|
||||
elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary exit code is not used: $TMP_EXIT_CODE" 1>&2
|
||||
@@ -428,12 +426,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_TARBALL"
|
||||
if [[ -e $TMP_TARBALL ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary tarball: $TMP_TARBALL" 1>&2
|
||||
exit 235
|
||||
exit 16
|
||||
fi
|
||||
:> "$TMP_TARBALL"
|
||||
if [[ ! -e $TMP_TARBALL ]]; then
|
||||
echo "$0: ERROR: cannot create temporary tarball: $TMP_TARBALL" 1>&2
|
||||
exit 236
|
||||
exit 17
|
||||
fi
|
||||
elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary tarball is not used: $TMP_TARBALL" 1>&2
|
||||
@@ -466,19 +464,19 @@ if [[ -z $NOOP ]]; then
|
||||
export FILELIST="$YYYY/.filelist"
|
||||
if [[ ! -e $FILELIST ]]; then
|
||||
echo "$0: ERROR: .filelist for $YYYY does not exist: $FILELIST" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -f $FILELIST ]]; then
|
||||
echo "$0: ERROR: .filelist for $YYYY is not a file: $FILELIST" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -r $FILELIST ]]; then
|
||||
echo "$0: ERROR: .filelist for $YYYY is not a readable file: $FILELIST" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -s $FILELIST ]]; then
|
||||
echo "$0: ERROR: .filelist for $YYYY is not a not a non-empty readable file: $FILELIST" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# load the year level into the IOCCC year's manifest
|
||||
@@ -489,15 +487,15 @@ if [[ -z $NOOP ]]; then
|
||||
#
|
||||
if [[ ! -e $YYYY ]]; then
|
||||
echo "$0: ERROR: YYYY does not exist: $YYYY" 1>&2
|
||||
exit 7
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $YYYY ]]; then
|
||||
echo "$0: ERROR: YYYY is not a directory: $YYYY" 1>&2
|
||||
exit 7
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -r $YYYY ]]; then
|
||||
echo "$0: ERROR: YYYY is not an readable directory: $YYYY" 1>&2
|
||||
exit 7
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify that YYYY has a non-empty readable .year file
|
||||
@@ -505,19 +503,19 @@ if [[ -z $NOOP ]]; then
|
||||
export YEAR_FILE="$YYYY/.year"
|
||||
if [[ ! -e $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year does not exist: $YEAR_FILE" 1>&2
|
||||
exit 7
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -f $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year is not a regular file: $YEAR_FILE" 1>&2
|
||||
exit 7
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -r $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year is not an readable file: $YEAR_FILE" 1>&2
|
||||
exit 7
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -s $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year is not a non-empty readable file: $YEAR_FILE" 1>&2
|
||||
exit 7
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# process each entry directory under YYYY
|
||||
@@ -535,33 +533,33 @@ if [[ -z $NOOP ]]; then
|
||||
#
|
||||
if [[ ! -d $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR is not a directory: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -w $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR is not a writable directory: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
export YEAR_DIR=${YYYY_DIR%%/*}
|
||||
if [[ -z $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR not in YYYY/dir form: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
export ENTRY_DIR=${YYYY_DIR#*/}
|
||||
if [[ -z $ENTRY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR not in $YEAR_DIR/dir form: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ $ENTRY_DIR = */* ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR: $YYYY_DIR dir contains a /: $ENTRY_DIR" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
@@ -570,19 +568,19 @@ if [[ -z $NOOP ]]; then
|
||||
#
|
||||
if [[ ! -e $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR does not exist: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -d $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR is not a directory: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -w $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR is not an writable directory: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
@@ -592,33 +590,33 @@ if [[ -z $NOOP ]]; then
|
||||
export DOT_PATH="$YYYY_DIR/.path"
|
||||
if [[ ! -s $DOT_PATH ]]; then
|
||||
echo "$0: ERROR: not a non-empty file: $DOT_PATH" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
DOT_PATH_CONTENT=$(< "$DOT_PATH")
|
||||
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_CODE="8" # exit 8
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
export ENTRY_JSON="$YYYY_DIR/.entry.json"
|
||||
if [[ ! -e $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json does not exist: $ENTRY_JSON" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -f $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a file: $ENTRY_JSON" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -r $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a readable file: $ENTRY_JSON" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
@@ -629,7 +627,7 @@ if [[ -z $NOOP ]]; then
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: awk -f $FILELIST_ENTRY_JSON_AWK $ENTRY_JSON >> $TMP_MANIFEST_LIST failed, error: $status" 1>&2
|
||||
exit 7
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# remove entry's tarball from the IOCCC year's manifest
|
||||
@@ -639,7 +637,7 @@ if [[ -z $NOOP ]]; then
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: sed -i '' -e '/$ENTRY_ID.tar.bz2/d' $TMP_MANIFEST_LIST failed, error: $status" 1>&2
|
||||
exit 7
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -649,7 +647,7 @@ if [[ -z $NOOP ]]; then
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: sort -d -u $TMP_MANIFEST_LIST -o $TMP_MANIFEST_LIST failed, error: $status" 1>&2
|
||||
exit 7
|
||||
exit 1
|
||||
fi
|
||||
|
||||
done
|
||||
@@ -701,7 +699,7 @@ fi
|
||||
EXIT_CODE=$(< "$TMP_EXIT_CODE")
|
||||
if [[ -z $EXIT_CODE ]]; then
|
||||
echo "$0: ERROR: temporary exit file is empty: $TMP_EXIT_CODE" 1>&2
|
||||
exit 233
|
||||
exit 18
|
||||
fi
|
||||
|
||||
# form the tarball
|
||||
@@ -736,7 +734,7 @@ if [[ -z $NOOP ]]; then
|
||||
"--owner=501 --group=20 --numeric-owner --totals" \
|
||||
"--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime" \
|
||||
"-jcvf $TMP_TARBALL < $TMP_TAR_LIST failed, error: $status" 1>&2
|
||||
EXIT_CODE=9 # exit 9
|
||||
EXIT_CODE=8 # exit 8
|
||||
fi
|
||||
|
||||
# case: form the tarball silently
|
||||
@@ -753,7 +751,7 @@ if [[ -z $NOOP ]]; then
|
||||
"--owner=501 --group=20 --numeric-owner" \
|
||||
"--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime" \
|
||||
"-jcf $TMP_TARBALL < $TMP_TAR_LIST failed, error: $status" 1>&2
|
||||
EXIT_CODE=9 # exit 9
|
||||
EXIT_CODE=8 # exit 8
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -761,7 +759,7 @@ if [[ -z $NOOP ]]; then
|
||||
#
|
||||
if [[ ! -s $TMP_TARBALL ]]; then
|
||||
echo "$0: ERROR: tarball is missing os empty: $TMP_TARBALL" 1>&2
|
||||
EXIT_CODE=9 # exit 9
|
||||
EXIT_CODE=8 # exit 8
|
||||
fi
|
||||
|
||||
# case: -n
|
||||
@@ -776,7 +774,7 @@ fi
|
||||
EXIT_CODE=$(< "$TMP_EXIT_CODE")
|
||||
if [[ -z $EXIT_CODE ]]; then
|
||||
echo "$0: ERROR: temporary exit file has no contents: $TMP_EXIT_CODE" 1>&2
|
||||
exit 234
|
||||
exit 19
|
||||
fi
|
||||
|
||||
# move the tarball in place only if different
|
||||
@@ -806,13 +804,13 @@ if [[ -z $NOOP ]]; then
|
||||
fi
|
||||
if [[ status -ne 0 ]]; then
|
||||
echo "$0: ERROR: mv -f -- $TMP_TARBALL $TARBALL filed, error code: $status" 1>&2
|
||||
EXIT_CODE=9 # exit 9
|
||||
EXIT_CODE=8 # exit 8
|
||||
elif [[ $V_FLAG -ge 1 ]]; then
|
||||
echo "$0: debug[1]: built replaced HTML file: $TARBALL" 1>&2
|
||||
fi
|
||||
if [[ ! -s $TARBALL ]]; then
|
||||
echo "$0: ERROR: not a non-empty index HTML file: $TARBALL" 1>&2
|
||||
EXIT_CODE=9 # exit 9
|
||||
EXIT_CODE=8 # exit 8
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
+68
-74
@@ -49,7 +49,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.0 2024-02-13"
|
||||
export VERSION="1.0.1 2024-02-23"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -57,7 +57,7 @@ GIT_TOOL=$(type -P git)
|
||||
export GIT_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: git tool is not installed or not in \$PATH" 1>&2
|
||||
exit 210
|
||||
exit 5
|
||||
fi
|
||||
"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
status="$?"
|
||||
@@ -71,7 +71,7 @@ GTAR_TOOL=$(type -P gtar)
|
||||
export GTAR_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: gtar (gnu tar) tool is not installed or not in \$PATH" 1>&2
|
||||
exit 9
|
||||
exit 8
|
||||
fi
|
||||
|
||||
# set usage message
|
||||
@@ -101,17 +101,15 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
|
||||
Exit codes:
|
||||
0 all OK
|
||||
1 some file in the .entry.json manifest is missing and -W was not used or no files were found
|
||||
1 some internal tool exited non-zero
|
||||
2 -h and help string printed or -V and version string printed
|
||||
3 command line error
|
||||
4 bash version is < 4.2
|
||||
5 YYYY/dir is not a entry directory
|
||||
6 bin/filelist.entry.json.awk is not a non-empty readable file
|
||||
7 error in trying to determine files used by the entry
|
||||
8 missing critical top level file
|
||||
9 gnu tar is missing or execution failed
|
||||
>= 10 < 210 ((not used))
|
||||
>= 210 internal tool error
|
||||
5 some internal tool is not found or not an executable file
|
||||
6 problems found with or in the topdir or topdir/YYYY directory
|
||||
7 problems found with or in the entry topdir/YYYY/dir directory
|
||||
8 gnu tar is missing or execution failed or error in forming compressed tarball
|
||||
>= 10 internal error
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
@@ -189,37 +187,28 @@ export REPO_NAME
|
||||
if [[ -z $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot find top of git repo directory" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 220
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR does not exist: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 221
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR is not a directory: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 222
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify that we have an 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 223
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to non-existent path: $TOPDIR" 1>&2
|
||||
exit 224
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to a non-directory: $TOPDIR" 1>&2
|
||||
exit 225
|
||||
exit 6
|
||||
fi
|
||||
export CD_FAILED
|
||||
if [[ $V_FLAG -ge 5 ]]; then
|
||||
@@ -228,63 +217,68 @@ fi
|
||||
cd "$TOPDIR" || CD_FAILED="true"
|
||||
if [[ -n $CD_FAILED ]]; then
|
||||
echo "$0: ERROR: cd $TOPDIR failed" 1>&2
|
||||
exit 226
|
||||
exit 6
|
||||
fi
|
||||
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
|
||||
# verify that we have an bin subdirectory
|
||||
#
|
||||
# ENTRY_PATH must be in YYYY/dir form
|
||||
# YYYY must be a directory
|
||||
# YYYY must be a writable directory
|
||||
# YYYY/.year must be a non-empty file
|
||||
# YYYY/dir must be a directory
|
||||
# YYYY/dir/.path must be a non-empty file
|
||||
# ENTRY_PATH must match the contents of YYYY/dir/.path
|
||||
# YYYY/dir/.entry.json must be a non-empty file
|
||||
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
|
||||
#
|
||||
if [[ ! -d $ENTRY_PATH ]]; then
|
||||
echo "$0: ERROR: arg is not a directory: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -w $ENTRY_PATH ]]; then
|
||||
echo "$0: ERROR: arg is not a writable directory: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
export YEAR_DIR=${ENTRY_PATH%%/*}
|
||||
if [[ -z $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: arg not in YYYY/dir form: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
export ENTRY_DIR=${ENTRY_PATH#*/}
|
||||
if [[ -z $ENTRY_DIR ]]; then
|
||||
echo "$0: ERROR: arg: $ENTRY_PATH not in $YEAR_DIR/dir form: $ENTRY_PATH" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
if [[ $ENTRY_DIR = */* ]]; then
|
||||
echo "$0: ERROR: dir from arg: $ENTRY_PATH contains a /: $ENTRY_DIR" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
if [[ ! -d $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY from arg: $ENTRY_PATH is not a directory: $YEAR_DIR" 1>&2
|
||||
exit 5
|
||||
exit 3
|
||||
fi
|
||||
export ENTRY_ID="${YEAR_DIR}_${ENTRY_DIR}"
|
||||
export DOT_YEAR="$YEAR_DIR/.year"
|
||||
if [[ ! -s $DOT_YEAR ]]; then
|
||||
echo "$0: ERROR: not a non-empty file: $DOT_YEAR" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
# Now that we have moved to topdir, form and verify YYYY_DIR is a writable directory
|
||||
export YYYY_DIR="$YEAR_DIR/$ENTRY_DIR"
|
||||
if [[ ! -e $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY/dir from arg: $ENTRY_PATH does not exist: $YYYY_DIR" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -d $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY/dir from arg: $ENTRY_PATH is not a directory: $YYYY_DIR" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
if [[ ! -w $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY/dir from arg: $ENTRY_PATH is not a writable directory: $YYYY_DIR" 1>&2
|
||||
exit 5
|
||||
exit 7
|
||||
fi
|
||||
export DOT_PATH="$YYYY_DIR/.path"
|
||||
if [[ ! -s $DOT_PATH ]]; then
|
||||
@@ -319,19 +313,19 @@ export TARBALL="$YYYY_DIR/$ENTRY_ID.tar.bz2"
|
||||
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 6
|
||||
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 6
|
||||
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 6
|
||||
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 6
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# verify we have non-empty readable ioccc.css file
|
||||
@@ -339,19 +333,19 @@ fi
|
||||
export IOCCC_CSS="ioccc.css"
|
||||
if [[ ! -e $IOCCC_CSS ]]; then
|
||||
echo "$0: ERROR: ioccc.css does not exist: $IOCCC_CSS" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -f $IOCCC_CSS ]]; then
|
||||
echo "$0: ERROR: ioccc.css is not a file: $IOCCC_CSS" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -r $IOCCC_CSS ]]; then
|
||||
echo "$0: ERROR: ioccc.css is not a readable file: $IOCCC_CSS" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -s $IOCCC_CSS ]]; then
|
||||
echo "$0: ERROR: ioccc.css is not a not a non-empty readable file: $IOCCC_CSS" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify we have non-empty readable ioccc.css file
|
||||
@@ -359,19 +353,19 @@ fi
|
||||
export VAR_MK="var.mk"
|
||||
if [[ ! -e $VAR_MK ]]; then
|
||||
echo "$0: ERROR: var.mk does not exist: $VAR_MK" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -f $VAR_MK ]]; then
|
||||
echo "$0: ERROR: var.mk is not a file: $VAR_MK" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -r $VAR_MK ]]; then
|
||||
echo "$0: ERROR: var.mk is not a readable file: $VAR_MK" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -s $VAR_MK ]]; then
|
||||
echo "$0: ERROR: var.mk is not a not a non-empty readable file: $VAR_MK" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# parameter debugging
|
||||
@@ -423,12 +417,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_MANIFEST_LIST"
|
||||
if [[ -e $TMP_MANIFEST_LIST ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary file manifest list: $TMP_MANIFEST_LIST" 1>&2
|
||||
exit 227
|
||||
exit 10
|
||||
fi
|
||||
:> "$TMP_MANIFEST_LIST"
|
||||
if [[ ! -e $TMP_MANIFEST_LIST ]]; then
|
||||
echo "$0: ERROR: cannot create temporary file manifest list: $TMP_MANIFEST_LIST" 1>&2
|
||||
exit 228
|
||||
exit 11
|
||||
fi
|
||||
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
|
||||
@@ -445,12 +439,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_TAR_LIST"
|
||||
if [[ -e $TMP_TAR_LIST ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary file tar list: $TMP_TAR_LIST" 1>&2
|
||||
exit 231
|
||||
exit 12
|
||||
fi
|
||||
:> "$TMP_TAR_LIST"
|
||||
if [[ ! -e $TMP_TAR_LIST ]]; then
|
||||
echo "$0: ERROR: cannot create temporary file tar list: $TMP_TAR_LIST" 1>&2
|
||||
exit 232
|
||||
exit 13
|
||||
fi
|
||||
elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary file tar list is not used: $TMP_TAR_LIST" 1>&2
|
||||
@@ -470,12 +464,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_EXIT_CODE"
|
||||
if [[ -e $TMP_EXIT_CODE ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary exit code: $TMP_EXIT_CODE" 1>&2
|
||||
exit 233
|
||||
exit 14
|
||||
fi
|
||||
echo "$EXIT_CODE" > "$TMP_EXIT_CODE"
|
||||
if [[ ! -e $TMP_EXIT_CODE ]]; then
|
||||
echo "$0: ERROR: cannot create temporary exit code: $TMP_EXIT_CODE" 1>&2
|
||||
exit 234
|
||||
exit 15
|
||||
fi
|
||||
elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary exit code is not used: $TMP_EXIT_CODE" 1>&2
|
||||
@@ -492,12 +486,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_TARBALL"
|
||||
if [[ -e $TMP_TARBALL ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary tarball: $TMP_TARBALL" 1>&2
|
||||
exit 231
|
||||
exit 16
|
||||
fi
|
||||
:> "$TMP_TARBALL"
|
||||
if [[ ! -e $TMP_TARBALL ]]; then
|
||||
echo "$0: ERROR: cannot create temporary tarball: $TMP_TARBALL" 1>&2
|
||||
exit 232
|
||||
exit 17
|
||||
fi
|
||||
elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary tarball is not used: $TMP_TARBALL" 1>&2
|
||||
@@ -512,7 +506,7 @@ if [[ -z $NOOP ]]; then
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: awk -f $FILELIST_ENTRY_JSON_AWK $ENTRY_JSON > $TMP_MANIFEST_LIST failed, error: $status" 1>&2
|
||||
exit 7
|
||||
exit 1
|
||||
fi
|
||||
echo "$IOCCC_CSS" >> "$TMP_MANIFEST_LIST"
|
||||
echo "$VAR_MK" >> "$TMP_MANIFEST_LIST"
|
||||
@@ -520,7 +514,7 @@ if [[ -z $NOOP ]]; then
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: sort -d -u $TMP_MANIFEST_LIST -o $TMP_MANIFEST_LIST failed, error: $status" 1>&2
|
||||
exit 7
|
||||
exit 1
|
||||
fi
|
||||
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
|
||||
@@ -563,7 +557,7 @@ fi
|
||||
EXIT_CODE=$(< "$TMP_EXIT_CODE")
|
||||
if [[ -z $EXIT_CODE ]]; then
|
||||
echo "$0: ERROR: temporary exit file is empty: $TMP_EXIT_CODE" 1>&2
|
||||
exit 233
|
||||
exit 18
|
||||
fi
|
||||
|
||||
# form the tarball
|
||||
@@ -592,7 +586,7 @@ if [[ -z $NOOP ]]; then
|
||||
"--owner=501 --group=20 --numeric-owner --totals" \
|
||||
"--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime" \
|
||||
"-jcvf $TMP_TARBALL < $TMP_TAR_LIST failed, error: $status" 1>&2
|
||||
EXIT_CODE=9 # exit 9
|
||||
EXIT_CODE=8 # exit 8
|
||||
fi
|
||||
|
||||
# case: form the tarball silently
|
||||
@@ -609,7 +603,7 @@ if [[ -z $NOOP ]]; then
|
||||
"--owner=501 --group=20 --numeric-owner" \
|
||||
"--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime" \
|
||||
"-jcf $TMP_TARBALL < $TMP_TAR_LIST failed, error: $status" 1>&2
|
||||
EXIT_CODE=9 # exit 9
|
||||
EXIT_CODE=8 # exit 8
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -617,7 +611,7 @@ if [[ -z $NOOP ]]; then
|
||||
#
|
||||
if [[ ! -s $TMP_TARBALL ]]; then
|
||||
echo "$0: ERROR: tarball is missing os empty: $TMP_TARBALL" 1>&2
|
||||
EXIT_CODE=9 # exit 9
|
||||
EXIT_CODE=8 # exit 8
|
||||
fi
|
||||
|
||||
# case: -n
|
||||
@@ -632,7 +626,7 @@ fi
|
||||
EXIT_CODE=$(< "$TMP_EXIT_CODE")
|
||||
if [[ -z $EXIT_CODE ]]; then
|
||||
echo "$0: ERROR: temporary exit file has no contents: $TMP_EXIT_CODE" 1>&2
|
||||
exit 234
|
||||
exit 19
|
||||
fi
|
||||
|
||||
# move the tarball in place only if different
|
||||
@@ -662,13 +656,13 @@ if [[ -z $NOOP ]]; then
|
||||
fi
|
||||
if [[ status -ne 0 ]]; then
|
||||
echo "$0: ERROR: mv -f -- $TMP_TARBALL $TARBALL filed, error code: $status" 1>&2
|
||||
EXIT_CODE=9 # exit 9
|
||||
EXIT_CODE=8 # exit 8
|
||||
elif [[ $V_FLAG -ge 1 ]]; then
|
||||
echo "$0: debug[1]: built replaced HTML file: $TARBALL" 1>&2
|
||||
fi
|
||||
if [[ ! -s $TARBALL ]]; then
|
||||
echo "$0: ERROR: not a non-empty index HTML file: $TARBALL" 1>&2
|
||||
EXIT_CODE=9 # exit 9
|
||||
EXIT_CODE=8 # exit 8
|
||||
fi
|
||||
fi
|
||||
elif [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -677,7 +671,7 @@ fi
|
||||
EXIT_CODE=$(< "$TMP_EXIT_CODE")
|
||||
if [[ -z $EXIT_CODE ]]; then
|
||||
echo "$0: ERROR: temporary exit file has no contents: $TMP_EXIT_CODE" 1>&2
|
||||
exit 234
|
||||
exit 20
|
||||
fi
|
||||
|
||||
# All Done!!! -- Jessica Noll, Age 2
|
||||
|
||||
+78
-80
@@ -49,7 +49,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.0 2024-02-17"
|
||||
export VERSION="1.0.1 2024-02-23"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -57,7 +57,7 @@ GIT_TOOL=$(type -P git)
|
||||
export GIT_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: git tool is not installed or not in \$PATH" 1>&2
|
||||
exit 210
|
||||
exit 5
|
||||
fi
|
||||
"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
status="$?"
|
||||
@@ -71,7 +71,7 @@ GTAR_TOOL=$(type -P gtar)
|
||||
export GTAR_TOOL
|
||||
if [[ -z "$GIT_TOOL" ]]; then
|
||||
echo "$0: FATAL: gtar (gnu tar) tool is not installed or not in \$PATH" 1>&2
|
||||
exit 9
|
||||
exit 8
|
||||
fi
|
||||
|
||||
# set usage message
|
||||
@@ -101,17 +101,15 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
|
||||
|
||||
Exit codes:
|
||||
0 all OK
|
||||
1 a file listed in .entry.json or .filelist is missing and -W was not used, or no files were found
|
||||
1 some internal tool exited non-zero
|
||||
2 -h and help string printed or -V and version string printed
|
||||
3 command line error
|
||||
4 bash version is < 4.2
|
||||
5 YYYY/dir is not a entry directory, or YYYY is not an IOCCC year
|
||||
6 bin/filelist.entry.json.awk is not a non-empty readable file
|
||||
7 error in trying to determine files used by the year
|
||||
8 missing critical top level file or missing .filelist file
|
||||
9 gnu tar is missing or execution failed
|
||||
>= 10 < 210 ((not used))
|
||||
>= 210 internal tool error
|
||||
5 some internal tool is not found or not an executable file
|
||||
6 problems found with or in the topdir or topdir/YYYY directory
|
||||
7 problems found with or in the entry topdir/YYYY/dir directory
|
||||
8 gnu tar is missing or execution failed or error in forming compressed tarball
|
||||
>= 10 internal error
|
||||
|
||||
$NAME version: $VERSION"
|
||||
|
||||
@@ -189,37 +187,28 @@ export REPO_NAME
|
||||
if [[ -z $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot find top of git repo directory" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 220
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR does not exist: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 221
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: TOPDIR is not a directory: $TOPDIR" 1>&2
|
||||
echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2
|
||||
exit 222
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify that we have an 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 223
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# cd to topdir
|
||||
#
|
||||
if [[ ! -e $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to non-existent path: $TOPDIR" 1>&2
|
||||
exit 224
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $TOPDIR ]]; then
|
||||
echo "$0: ERROR: cannot cd to a non-directory: $TOPDIR" 1>&2
|
||||
exit 225
|
||||
exit 6
|
||||
fi
|
||||
export CD_FAILED
|
||||
if [[ $V_FLAG -ge 5 ]]; then
|
||||
@@ -228,12 +217,21 @@ fi
|
||||
cd "$TOPDIR" || CD_FAILED="true"
|
||||
if [[ -n $CD_FAILED ]]; then
|
||||
echo "$0: ERROR: cd $TOPDIR failed" 1>&2
|
||||
exit 226
|
||||
exit 6
|
||||
fi
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
|
||||
fi
|
||||
|
||||
# verify that we have an 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"
|
||||
|
||||
# determine the name of our tarball
|
||||
#
|
||||
export TARBALL="$YYYY/$YYYY.tar.bz2"
|
||||
@@ -243,19 +241,19 @@ export TARBALL="$YYYY/$YYYY.tar.bz2"
|
||||
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 6
|
||||
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 6
|
||||
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 6
|
||||
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 6
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# verify we have non-empty readable ioccc.css file
|
||||
@@ -263,19 +261,19 @@ fi
|
||||
export IOCCC_CSS="ioccc.css"
|
||||
if [[ ! -e $IOCCC_CSS ]]; then
|
||||
echo "$0: ERROR: ioccc.css does not exist: $IOCCC_CSS" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -f $IOCCC_CSS ]]; then
|
||||
echo "$0: ERROR: ioccc.css is not a file: $IOCCC_CSS" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -r $IOCCC_CSS ]]; then
|
||||
echo "$0: ERROR: ioccc.css is not a readable file: $IOCCC_CSS" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -s $IOCCC_CSS ]]; then
|
||||
echo "$0: ERROR: ioccc.css is not a not a non-empty readable file: $IOCCC_CSS" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify we have non-empty readable ioccc.css file
|
||||
@@ -283,19 +281,19 @@ fi
|
||||
export VAR_MK="var.mk"
|
||||
if [[ ! -e $VAR_MK ]]; then
|
||||
echo "$0: ERROR: var.mk does not exist: $VAR_MK" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -f $VAR_MK ]]; then
|
||||
echo "$0: ERROR: var.mk is not a file: $VAR_MK" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -r $VAR_MK ]]; then
|
||||
echo "$0: ERROR: var.mk is not a readable file: $VAR_MK" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -s $VAR_MK ]]; then
|
||||
echo "$0: ERROR: var.mk is not a not a non-empty readable file: $VAR_MK" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify we have non-empty readable year level .filelist file
|
||||
@@ -303,19 +301,19 @@ fi
|
||||
export FILELIST="$YYYY/.filelist"
|
||||
if [[ ! -e $FILELIST ]]; then
|
||||
echo "$0: ERROR: .filelist for $YYYY does not exist: $FILELIST" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -f $FILELIST ]]; then
|
||||
echo "$0: ERROR: .filelist for $YYYY is not a file: $FILELIST" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -r $FILELIST ]]; then
|
||||
echo "$0: ERROR: .filelist for $YYYY is not a readable file: $FILELIST" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -s $FILELIST ]]; then
|
||||
echo "$0: ERROR: .filelist for $YYYY is not a not a non-empty readable file: $FILELIST" 1>&2
|
||||
exit 8
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# parameter debugging
|
||||
@@ -363,12 +361,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_MANIFEST_LIST"
|
||||
if [[ -e $TMP_MANIFEST_LIST ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary file manifest list: $TMP_MANIFEST_LIST" 1>&2
|
||||
exit 227
|
||||
exit 10
|
||||
fi
|
||||
:> "$TMP_MANIFEST_LIST"
|
||||
if [[ ! -e $TMP_MANIFEST_LIST ]]; then
|
||||
echo "$0: ERROR: cannot create temporary file manifest list: $TMP_MANIFEST_LIST" 1>&2
|
||||
exit 228
|
||||
exit 11
|
||||
fi
|
||||
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
|
||||
@@ -385,12 +383,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_TAR_LIST"
|
||||
if [[ -e $TMP_TAR_LIST ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary file tar list: $TMP_TAR_LIST" 1>&2
|
||||
exit 231
|
||||
exit 12
|
||||
fi
|
||||
:> "$TMP_TAR_LIST"
|
||||
if [[ ! -e $TMP_TAR_LIST ]]; then
|
||||
echo "$0: ERROR: cannot create temporary file tar list: $TMP_TAR_LIST" 1>&2
|
||||
exit 232
|
||||
exit 13
|
||||
fi
|
||||
elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary file tar list is not used: $TMP_TAR_LIST" 1>&2
|
||||
@@ -410,12 +408,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_EXIT_CODE"
|
||||
if [[ -e $TMP_EXIT_CODE ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary exit code: $TMP_EXIT_CODE" 1>&2
|
||||
exit 233
|
||||
exit 14
|
||||
fi
|
||||
echo "$EXIT_CODE" > "$TMP_EXIT_CODE"
|
||||
if [[ ! -e $TMP_EXIT_CODE ]]; then
|
||||
echo "$0: ERROR: cannot create temporary exit code: $TMP_EXIT_CODE" 1>&2
|
||||
exit 234
|
||||
exit 15
|
||||
fi
|
||||
elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary exit code is not used: $TMP_EXIT_CODE" 1>&2
|
||||
@@ -432,12 +430,12 @@ if [[ -z $NOOP ]]; then
|
||||
rm -f "$TMP_TARBALL"
|
||||
if [[ -e $TMP_TARBALL ]]; then
|
||||
echo "$0: ERROR: cannot remove temporary tarball: $TMP_TARBALL" 1>&2
|
||||
exit 231
|
||||
exit 16
|
||||
fi
|
||||
:> "$TMP_TARBALL"
|
||||
if [[ ! -e $TMP_TARBALL ]]; then
|
||||
echo "$0: ERROR: cannot create temporary tarball: $TMP_TARBALL" 1>&2
|
||||
exit 232
|
||||
exit 17
|
||||
fi
|
||||
elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: because of -n, temporary tarball is not used: $TMP_TARBALL" 1>&2
|
||||
@@ -461,15 +459,15 @@ if [[ -z $NOOP ]]; then
|
||||
#
|
||||
if [[ ! -e $YYYY ]]; then
|
||||
echo "$0: ERROR: YYYY does not exist: $YYYY" 1>&2
|
||||
exit 7
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -d $YYYY ]]; then
|
||||
echo "$0: ERROR: YYYY is not a directory: $YYYY" 1>&2
|
||||
exit 7
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -r $YYYY ]]; then
|
||||
echo "$0: ERROR: YYYY is not an readable directory: $YYYY" 1>&2
|
||||
exit 7
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# verify that YYYY has a non-empty readable .year file
|
||||
@@ -477,19 +475,19 @@ if [[ -z $NOOP ]]; then
|
||||
export YEAR_FILE="$YYYY/.year"
|
||||
if [[ ! -e $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year does not exist: $YEAR_FILE" 1>&2
|
||||
exit 7
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -f $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year is not a regular file: $YEAR_FILE" 1>&2
|
||||
exit 7
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -r $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year is not an readable file: $YEAR_FILE" 1>&2
|
||||
exit 7
|
||||
exit 6
|
||||
fi
|
||||
if [[ ! -s $YEAR_FILE ]]; then
|
||||
echo "$0: ERROR: YYYY/.year is not a non-empty readable file: $YEAR_FILE" 1>&2
|
||||
exit 7
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# process each entry directory under YYYY
|
||||
@@ -507,33 +505,33 @@ if [[ -z $NOOP ]]; then
|
||||
#
|
||||
if [[ ! -d $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR is not a directory: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -w $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR is not a writable directory: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
export YEAR_DIR=${YYYY_DIR%%/*}
|
||||
if [[ -z $YEAR_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR not in YYYY/dir form: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
export ENTRY_DIR=${YYYY_DIR#*/}
|
||||
if [[ -z $ENTRY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR not in $YEAR_DIR/dir form: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ $ENTRY_DIR = */* ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR: $YYYY_DIR dir contains a /: $ENTRY_DIR" 1>&2
|
||||
EXIT_CODE="7" # exit 7
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
@@ -542,19 +540,19 @@ if [[ -z $NOOP ]]; then
|
||||
#
|
||||
if [[ ! -e $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR does not exist: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -d $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR is not a directory: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -w $YYYY_DIR ]]; then
|
||||
echo "$0: ERROR: YYYY_DIR is not an writable directory: $YYYY_DIR" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
@@ -564,33 +562,33 @@ if [[ -z $NOOP ]]; then
|
||||
export DOT_PATH="$YYYY_DIR/.path"
|
||||
if [[ ! -s $DOT_PATH ]]; then
|
||||
echo "$0: ERROR: not a non-empty file: $DOT_PATH" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
DOT_PATH_CONTENT=$(< "$DOT_PATH")
|
||||
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_CODE="8" # exit 8
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
export ENTRY_JSON="$YYYY_DIR/.entry.json"
|
||||
if [[ ! -e $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json does not exist: $ENTRY_JSON" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -f $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a file: $ENTRY_JSON" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
if [[ ! -r $ENTRY_JSON ]]; then
|
||||
echo "$0: ERROR: .entry.json is not a readable file: $ENTRY_JSON" 1>&2
|
||||
EXIT_CODE="8" # exit 8
|
||||
EXIT_CODE=7 # exit 7
|
||||
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
|
||||
continue
|
||||
fi
|
||||
@@ -601,7 +599,7 @@ if [[ -z $NOOP ]]; then
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: awk -f $FILELIST_ENTRY_JSON_AWK $ENTRY_JSON >> $TMP_MANIFEST_LIST failed, error: $status" 1>&2
|
||||
exit 7
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# remove entry's tarball from the IOCCC year's manifest
|
||||
@@ -611,7 +609,7 @@ if [[ -z $NOOP ]]; then
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: sed -i '' -e '/$ENTRY_ID.tar.bz2/d' $TMP_MANIFEST_LIST failed, error: $status" 1>&2
|
||||
exit 7
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -621,7 +619,7 @@ if [[ -z $NOOP ]]; then
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: sort -d -u $TMP_MANIFEST_LIST -o $TMP_MANIFEST_LIST failed, error: $status" 1>&2
|
||||
exit 7
|
||||
exit 1
|
||||
fi
|
||||
|
||||
elif [[ $V_FLAG -ge 3 ]]; then
|
||||
@@ -665,7 +663,7 @@ fi
|
||||
EXIT_CODE=$(< "$TMP_EXIT_CODE")
|
||||
if [[ -z $EXIT_CODE ]]; then
|
||||
echo "$0: ERROR: temporary exit file is empty: $TMP_EXIT_CODE" 1>&2
|
||||
exit 233
|
||||
exit 18
|
||||
fi
|
||||
|
||||
# form the tarball
|
||||
@@ -694,7 +692,7 @@ if [[ -z $NOOP ]]; then
|
||||
"--owner=501 --group=20 --numeric-owner --totals" \
|
||||
"--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime" \
|
||||
"-jcvf $TMP_TARBALL < $TMP_TAR_LIST failed, error: $status" 1>&2
|
||||
EXIT_CODE=9 # exit 9
|
||||
EXIT_CODE=8 # exit 8
|
||||
fi
|
||||
|
||||
# case: form the tarball silently
|
||||
@@ -711,7 +709,7 @@ if [[ -z $NOOP ]]; then
|
||||
"--owner=501 --group=20 --numeric-owner" \
|
||||
"--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime" \
|
||||
"-jcf $TMP_TARBALL < $TMP_TAR_LIST failed, error: $status" 1>&2
|
||||
EXIT_CODE=9 # exit 9
|
||||
EXIT_CODE=8 # exit 8
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -719,7 +717,7 @@ if [[ -z $NOOP ]]; then
|
||||
#
|
||||
if [[ ! -s $TMP_TARBALL ]]; then
|
||||
echo "$0: ERROR: tarball is missing os empty: $TMP_TARBALL" 1>&2
|
||||
EXIT_CODE=9 # exit 9
|
||||
EXIT_CODE=8 # exit 8
|
||||
fi
|
||||
|
||||
# case: -n
|
||||
@@ -734,7 +732,7 @@ fi
|
||||
EXIT_CODE=$(< "$TMP_EXIT_CODE")
|
||||
if [[ -z $EXIT_CODE ]]; then
|
||||
echo "$0: ERROR: temporary exit file has no contents: $TMP_EXIT_CODE" 1>&2
|
||||
exit 234
|
||||
exit 19
|
||||
fi
|
||||
|
||||
# move the tarball in place only if different
|
||||
@@ -764,13 +762,13 @@ if [[ -z $NOOP ]]; then
|
||||
fi
|
||||
if [[ status -ne 0 ]]; then
|
||||
echo "$0: ERROR: mv -f -- $TMP_TARBALL $TARBALL filed, error code: $status" 1>&2
|
||||
EXIT_CODE=9 # exit 9
|
||||
EXIT_CODE=8 # exit 8
|
||||
elif [[ $V_FLAG -ge 1 ]]; then
|
||||
echo "$0: debug[1]: built replaced HTML file: $TARBALL" 1>&2
|
||||
fi
|
||||
if [[ ! -s $TARBALL ]]; then
|
||||
echo "$0: ERROR: not a non-empty index HTML file: $TARBALL" 1>&2
|
||||
EXIT_CODE=9 # exit 9
|
||||
EXIT_CODE=8 # exit 8
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
Reference in new issue
Block a user