improved how stat tool is used
Detect were the stat tool is located. If no stat tool is found, set `$STAT_TOOL` to `false`. Cleanup comments related to determining the modification time of a file. Changed `bin/gen-sitemap.sh` VERSION from "1.3.8 2024-04-28" to "1.3.9 2024-06-21". Changed `bin/gen-status.sh` VERSION from "1.5.2 2024-04-30" to "1.5.3 2024-06-21". Perform `make www` to perform the above and test under macOS.
This commit is contained in:
1 parent
8fb4edb6f5
commit
ccc53f83e5
2 files changed
+15
-24
No files matched your search
+13
-15
@@ -84,7 +84,7 @@ shopt -s globstar # enable ** to match all files and zero or more directories an
|
|||||||
|
|
||||||
# set variables referenced in the usage message
|
# set variables referenced in the usage message
|
||||||
#
|
#
|
||||||
export VERSION="1.3.8 2024-04-28"
|
export VERSION="1.3.9 2024-06-21"
|
||||||
NAME=$(basename "$0")
|
NAME=$(basename "$0")
|
||||||
export NAME
|
export NAME
|
||||||
export V_FLAG=0
|
export V_FLAG=0
|
||||||
@@ -104,6 +104,10 @@ export REPO_URL="https://github.com/ioccc-src/temp-test-ioccc/blob/master"
|
|||||||
export SITE_URL="https://ioccc-src.github.io/temp-test-ioccc"
|
export SITE_URL="https://ioccc-src.github.io/temp-test-ioccc"
|
||||||
export CAP_W_FLAG_FOUND=
|
export CAP_W_FLAG_FOUND=
|
||||||
export MODTIME_METHOD=""
|
export MODTIME_METHOD=""
|
||||||
|
STAT_TOOL=$(type -P stat)
|
||||||
|
if [[ -z "$STAT_TOOL" ]]; then
|
||||||
|
STAT_TOOL="false" # we have no stat tool
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# output_modtime - file modification time in W3C Datetime format:
|
# output_modtime - file modification time in W3C Datetime format:
|
||||||
@@ -136,11 +140,11 @@ function output_modtime
|
|||||||
# macOS stat
|
# macOS stat
|
||||||
#
|
#
|
||||||
macos_stat)
|
macos_stat)
|
||||||
TZ=UTC stat -f '%Sm' -t '%FT%T+00:00' "$FILENAME"
|
TZ=UTC "$STAT_TOOL" -f '%Sm' -t '%FT%T+00:00' "$FILENAME"
|
||||||
status="$?"
|
status="$?"
|
||||||
if [[ $status -ne 0 ]]; then
|
if [[ $status -ne 0 ]]; then
|
||||||
echo "$0: ERROR: in output_modtime:" \
|
echo "$0: ERROR: in output_modtime:" \
|
||||||
"TZ=UTC stat -f '%Sm' -t '%FT%T+00:00' $FILENAME failed, error code: $status" 1>&2
|
"TZ=UTC $STAT_TOOL -f '%Sm' -t '%FT%T+00:00' $FILENAME failed, error code: $status" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@@ -148,12 +152,12 @@ function output_modtime
|
|||||||
# RHEL Linux stat
|
# RHEL Linux stat
|
||||||
#
|
#
|
||||||
RHEL_stat)
|
RHEL_stat)
|
||||||
TZ=UTC stat -c '%y' "$FILENAME" | sed -e 's/ /T/' -e 's/\.[0-9]* //' -e 's/\([0-9][0-9]\)$/:&/'
|
TZ=UTC "$STAT_TOOL" -c '%y' "$FILENAME" | sed -e 's/ /T/' -e 's/\.[0-9]* //' -e 's/\([0-9][0-9]\)$/:&/'
|
||||||
status0="${PIPESTATUS[0]}"
|
status0="${PIPESTATUS[0]}"
|
||||||
status1="${PIPESTATUS[1]}"
|
status1="${PIPESTATUS[1]}"
|
||||||
if [[ $status0 -ne 0 || $status1 -ne 0 ]]; then
|
if [[ $status0 -ne 0 || $status1 -ne 0 ]]; then
|
||||||
echo "$0: ERROR: in output_modtime:" \
|
echo "$0: ERROR: in output_modtime:" \
|
||||||
"TZ=UTC stat -c '%y' $FILENAME | sed .. failed, error codes: $status0 and $status1" 1>&2
|
"TZ=UTC $STAT_TOOL -c '%y' $FILENAME | sed .. failed, error codes: $status0 and $status1" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@@ -422,38 +426,32 @@ fi
|
|||||||
#
|
#
|
||||||
# Try macOS stat:
|
# Try macOS stat:
|
||||||
#
|
#
|
||||||
# TZ=UTC stat -f '%Sm' -t '%FT%T+00:00' filename
|
TZ=UTC "$STAT_TOOL" -f '%Sm' -t '%FT%T+00:00' "$TOP_FILE" > /dev/null 2>&1
|
||||||
#
|
|
||||||
TZ=UTC stat -f '%Sm' -t '%FT%T+00:00' "$TOP_FILE" > /dev/null 2>&1
|
|
||||||
status="$?"
|
status="$?"
|
||||||
if [[ $status -eq 0 ]]; then
|
if [[ $status -eq 0 ]]; then
|
||||||
MODTIME_METHOD="macos_stat"
|
MODTIME_METHOD="macos_stat"
|
||||||
if [[ $V_FLAG -ge 5 ]]; then
|
if [[ $V_FLAG -ge 5 ]]; then
|
||||||
echo "$0: debug[5]: TZ=UTC stat -f '%Sm' -t '%FT%T+00:00' works, MODTIME_METHOD: $MODTIME_METHOD" 1>&2
|
echo "$0: debug[5]: TZ=UTC $STAT_TOOL -f '%Sm' -t '%FT%T+00:00' works, MODTIME_METHOD: $MODTIME_METHOD" 1>&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
# Try RHEL Linux stat:
|
# Try RHEL Linux stat:
|
||||||
#
|
#
|
||||||
# TZ=UTC stat -c '%y' faq.md | sed -e 's/ /T/' -e 's/\.[0-9]* //' -e 's/\([0-9][0-9]\)$/:&/'
|
|
||||||
#
|
|
||||||
# NOTE: We only need to test the stat command.
|
# NOTE: We only need to test the stat command.
|
||||||
#
|
#
|
||||||
TZ=UTC stat -c '%y' "$TOP_FILE" > /dev/null 2>&1
|
TZ=UTC "$STAT_TOOL" -c '%y' "$TOP_FILE" > /dev/null 2>&1
|
||||||
status="$?"
|
status="$?"
|
||||||
if [[ $status -eq 0 ]]; then
|
if [[ $status -eq 0 ]]; then
|
||||||
MODTIME_METHOD="RHEL_stat"
|
MODTIME_METHOD="RHEL_stat"
|
||||||
if [[ $V_FLAG -ge 5 ]]; then
|
if [[ $V_FLAG -ge 5 ]]; then
|
||||||
echo "$0: debug[5]: TZ=UTC stat -c '%y' works, MODTIME_METHOD: $MODTIME_METHOD" 1>&2
|
echo "$0: debug[5]: TZ=UTC $STAT_TOOL -c '%y' works, MODTIME_METHOD: $MODTIME_METHOD" 1>&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
# Try ls -D:
|
# Try ls -D:
|
||||||
#
|
#
|
||||||
# TZ=UTZ ls -D '%FT%T+00:00' -ld
|
|
||||||
#
|
|
||||||
TZ=UTZ ls -D '%FT%T+00:00' -ld "$TOP_FILE" > /dev/null 2>&1
|
TZ=UTZ ls -D '%FT%T+00:00' -ld "$TOP_FILE" > /dev/null 2>&1
|
||||||
status="$?"
|
status="$?"
|
||||||
if [[ $status -eq 0 ]]; then
|
if [[ $status -eq 0 ]]; then
|
||||||
|
|||||||
+2
-9
@@ -84,7 +84,7 @@ shopt -s globstar # enable ** to match all files and zero or more directories an
|
|||||||
|
|
||||||
# set variables referenced in the usage message
|
# set variables referenced in the usage message
|
||||||
#
|
#
|
||||||
export VERSION="1.5.2 2024-04-30"
|
export VERSION="1.5.3 2024-06-21"
|
||||||
NAME=$(basename "$0")
|
NAME=$(basename "$0")
|
||||||
export NAME
|
export NAME
|
||||||
export V_FLAG=0
|
export V_FLAG=0
|
||||||
@@ -113,8 +113,7 @@ if [[ -z "$JPARSE_TOOL" ]]; then
|
|||||||
fi
|
fi
|
||||||
STAT_TOOL=$(type -P stat)
|
STAT_TOOL=$(type -P stat)
|
||||||
if [[ -z "$STAT_TOOL" ]]; then
|
if [[ -z "$STAT_TOOL" ]]; then
|
||||||
echo "$0: FATAL: stat tool is not installed or not in \$PATH" 1>&2
|
STAT_TOOL="false" # we have no stat tool
|
||||||
exit 5
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
LS_TOOL=$(type -P ls)
|
LS_TOOL=$(type -P ls)
|
||||||
@@ -697,8 +696,6 @@ export NEXT_DIR="next"
|
|||||||
#
|
#
|
||||||
# Try macOS stat:
|
# Try macOS stat:
|
||||||
#
|
#
|
||||||
# TZ=UTC stat -f '%Sm' -t '%FT%T+00:00' filename
|
|
||||||
#
|
|
||||||
TZ=UTC "$STAT_TOOL" -f '%Sm' -t '%FT%T+00:00' "$TOP_FILE" > /dev/null 2>&1
|
TZ=UTC "$STAT_TOOL" -f '%Sm' -t '%FT%T+00:00' "$TOP_FILE" > /dev/null 2>&1
|
||||||
status="$?"
|
status="$?"
|
||||||
if [[ $status -eq 0 ]]; then
|
if [[ $status -eq 0 ]]; then
|
||||||
@@ -711,8 +708,6 @@ else
|
|||||||
|
|
||||||
# Try RHEL Linux stat:
|
# Try RHEL Linux stat:
|
||||||
#
|
#
|
||||||
# TZ=UTC stat -c '%y' faq.md | sed -e 's/ /T/' -e 's/\.[0-9]* //' -e 's/\([0-9][0-9]\)$/:&/'
|
|
||||||
#
|
|
||||||
# NOTE: We only need to test the stat command.
|
# NOTE: We only need to test the stat command.
|
||||||
#
|
#
|
||||||
TZ=UTC "$STAT_TOOL" -c '%y' "$TOP_FILE" > /dev/null 2>&1
|
TZ=UTC "$STAT_TOOL" -c '%y' "$TOP_FILE" > /dev/null 2>&1
|
||||||
@@ -727,8 +722,6 @@ else
|
|||||||
|
|
||||||
# Try ls -D:
|
# Try ls -D:
|
||||||
#
|
#
|
||||||
# TZ=UTZ ls -D '%FT%T+00:00' -ld
|
|
||||||
#
|
|
||||||
TZ=UTZ "$LS_TOOL" -D '%FT%T+00:00' -ld "$TOP_FILE" > /dev/null 2>&1
|
TZ=UTZ "$LS_TOOL" -D '%FT%T+00:00' -ld "$TOP_FILE" > /dev/null 2>&1
|
||||||
status="$?"
|
status="$?"
|
||||||
if [[ $status -eq 0 ]]; then
|
if [[ $status -eq 0 ]]; then
|
||||||
|
|||||||
Reference in new issue
Block a user