use more bin/jval-wrapper.sh instead of direct grep of JSON files
We use the `bin/jval-wrapper.sh` tool to obtain information from JSON files instead of attempting using a "GROSS HACK" that involved using `grep(1)` (and friends) as those "GROSS HACK"s assumed that the layout of the JSON was canonical. The `bin/jval-wrapper.sh` tool is able to deal with various layouts of JSON including non-canonical layouts. Moreover, by using the `bin/jval-wrapper.sh` tool we greatly reduce the places in bin tools that contain "GROSS HACK"s. Adjusted `bin/subst.entry-index.sh` to use `bin/jval-wrapper.sh`. Changed `bin/subst.entry-index.sh` VERSION from "1.4 2024-08-09" to "1.5 2024-08-13". Adjusted `bin/entry2csv.sh` to use `bin/jval-wrapper.sh`. Changed `bin/entry2csv.sh` VERSION from "1.1.1 2024-07-22" to "1.2 2024-08-13". Performed `make entry2csv` to test the above under macOS. Adjusted `bin/csv2entry.sh` to use `bin/jval-wrapper.sh`. Changed `bin/entry2csv.sh` VERSION from "1.1.1 2024-07-22" to "1.2 2024-08-13". Performed `make csv2entry` to test the above under macOS.
This commit is contained in:
1 parent
317a2a0c2c
commit
5c66aaa1f2
3 files changed
+49
-70
No files matched your search
@@ -103,7 +103,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-08-09"
|
||||
export VERSION="1.5 2024-08-13"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -181,7 +181,6 @@ $NAME version: $VERSION"
|
||||
function output_award
|
||||
{
|
||||
local ENTRY_JSON_PATH; # the .entry.json path
|
||||
local AWARD_STRING; # winning entry award string
|
||||
|
||||
# parse args
|
||||
#
|
||||
@@ -205,12 +204,7 @@ function output_award
|
||||
|
||||
# obtain the award string
|
||||
#
|
||||
AWARD_STRING=$(grep -F '"award" : "' "$ENTRY_JSON_PATH" | sed -e 's/^.*"award" : "//' -e 's/",//')
|
||||
if [[ -z $AWARD_STRING ]]; then
|
||||
echo "$0: ERROR: in output_award: no award found in .entry.json file: $ENTRY_JSON_PATH" 1>&2
|
||||
return 5
|
||||
fi
|
||||
echo "$AWARD_STRING"
|
||||
"$JVAL_WRAPPER" -w -b "$ENTRY_JSON_PATH" '$..award'
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -362,6 +356,14 @@ if [[ ! -d $BIN_PATH ]]; then
|
||||
fi
|
||||
export BIN_DIR="bin"
|
||||
|
||||
# find the jval-wrapper.sh tool
|
||||
#
|
||||
JVAL_WRAPPER="$BIN_PATH/jval-wrapper.sh"
|
||||
if [[ ! -x $JVAL_WRAPPER ]]; then
|
||||
echo "$0: ERROR: cannot find the bin/jval-wrapper.sh executable" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# verify that ENTRY_PATH is a entry directory
|
||||
#
|
||||
if [[ ! -d $ENTRY_PATH ]]; then
|
||||
@@ -483,6 +485,7 @@ if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: INC_DIR=$INC_DIR" 1>&2
|
||||
echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2
|
||||
echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2
|
||||
echo "$0: debug[3]: JVAL_WRAPPER=$JVAL_WRAPPER" 1>&2
|
||||
echo "$0: debug[3]: YEAR_DIR=$YEAR_DIR" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_DIR=$ENTRY_DIR" 1>&2
|
||||
echo "$0: debug[3]: ENTRY_ID=$ENTRY_ID" 1>&2
|
||||
|
||||
Reference in new issue
Block a user