From 3dacba6a44e5a6c8f2c7eb86275c20f3e67a747d Mon Sep 17 00:00:00 2001 From: Landon Curt Noll Date: Fri, 21 Jun 2024 22:13:28 -0700 Subject: [PATCH] complete stat fix The previous commit missed changes related to the LS_TOOL. Perform `make www` to perform the above and test under macOS. --- bin/gen-sitemap.sh | 17 +++++++++++++---- bin/gen-status.sh | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/bin/gen-sitemap.sh b/bin/gen-sitemap.sh index 92a614475..379d247d1 100755 --- a/bin/gen-sitemap.sh +++ b/bin/gen-sitemap.sh @@ -104,10 +104,17 @@ 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 CAP_W_FLAG_FOUND= export MODTIME_METHOD="" +# STAT_TOOL=$(type -P stat) if [[ -z "$STAT_TOOL" ]]; then STAT_TOOL="false" # we have no stat tool fi +# +LS_TOOL=$(type -P ls) +if [[ -z "$LS_TOOL" ]]; then + echo "$0: FATAL: ls tool is not installed or not in \$PATH" 1>&2 + exit 5 +fi # output_modtime - file modification time in W3C Datetime format: @@ -168,12 +175,12 @@ function output_modtime # SC2012 (info): Use find instead of ls to better handle non-alphanumeric filenames. # https://www.shellcheck.net/wiki/SC2012 # shellcheck disable=SC2012 - TZ=UTZ ls -D '%FT%T+00:00' -ld "$FILENAME" | awk '{print $6;}' + TZ=UTZ "$LS_TOOL" -D '%FT%T+00:00' -ld "$FILENAME" | awk '{print $6;}' status0="${PIPESTATUS[0]}" status1="${PIPESTATUS[1]}" if [[ $status0 -ne 0 || $status1 -ne 0 ]]; then echo "$0: ERROR: in output_modtime:" \ - "TZ=UTZ ls -D '%FT%T+00:00' -ld $FILENAME | awk .. failed, error codes: $status0 and $status1" 1>&2 + "TZ=UTZ $LS_TOOL -D '%FT%T+00:00' -ld $FILENAME | awk .. failed, error codes: $status0 and $status1" 1>&2 exit 1 fi ;; @@ -452,12 +459,12 @@ else # Try ls -D: # - TZ=UTZ ls -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="$?" if [[ $status -eq 0 ]]; then MODTIME_METHOD="ls_D" if [[ $V_FLAG -ge 5 ]]; then - echo "$0: debug[5]: TZ=UTZ ls -D '%FT%T+00:00' -ld works, MODTIME_METHOD: $MODTIME_METHOD" 1>&2 + echo "$0: debug[5]: TZ=UTZ $LS_TOOL -D '%FT%T+00:00' -ld works, MODTIME_METHOD: $MODTIME_METHOD" 1>&2 fi else @@ -479,6 +486,8 @@ if [[ $V_FLAG -ge 3 ]]; then echo "$0: debug[3]: SITE_URL=$SITE_URL" 1>&2 echo "$0: debug[3]: CAP_W_FLAG_FOUND=$CAP_W_FLAG_FOUND" 1>&2 echo "$0: debug[3]: MODTIME_METHOD=$MODTIME_METHOD" 1>&2 + echo "$0: debug[3]: STAT_TOOL=$STAT_TOOL" 1>&2 + echo "$0: debug[3]: LS_TOOL=$LS_TOOL" 1>&2 echo "$0: debug[3]: NOOP=$NOOP" 1>&2 echo "$0: debug[3]: DO_NOT_PROCESS=$DO_NOT_PROCESS" 1>&2 echo "$0: debug[3]: EXIT_CODE=$EXIT_CODE" 1>&2 diff --git a/bin/gen-status.sh b/bin/gen-status.sh index 8e2041f21..89b1e4999 100755 --- a/bin/gen-status.sh +++ b/bin/gen-status.sh @@ -111,11 +111,12 @@ if [[ -z "$JPARSE_TOOL" ]]; then echo "$0: FATAL: jparse tool is not installed or not in \$PATH" 1>&2 exit 5 fi +# STAT_TOOL=$(type -P stat) if [[ -z "$STAT_TOOL" ]]; then STAT_TOOL="false" # we have no stat tool fi - +# LS_TOOL=$(type -P ls) if [[ -z "$LS_TOOL" ]]; then echo "$0: FATAL: ls tool is not installed or not in \$PATH" 1>&2