fix how tools check exit codes an entire pipe
We use the `status_codes=("${PIPESTATUS[@]}")` method to
collect all of the bash exit codes from a pipe in one go,
and then test for any failure with `[[ ${status_codes[*]} =~ [1-9] ]]`.
There are other cases where an exit code is obtained,
however in each of those cases only a single exit code
from just one of the commands in the pipe is needed.
In `bin/gen-sitemap.sh` changed VERSION from "1.3.9 2024-06-21"
to "1.3.10 2024-07-18".
In `bin/gen-status.sh` changed VERSION from "1.5.4 2024-07-18"
to "1.5.5 2024-07-18".
Performed `make www` to accomplish the above and to test under macOS.
This commit is contained in:
1 parent
ef35efc4d3
commit
be94c60316
2 files changed
+18
-18
No files matched your search
+9
-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
|
||||
#
|
||||
export VERSION="1.3.9 2024-06-21"
|
||||
export VERSION="1.3.10 2024-07-18"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -160,11 +160,11 @@ function output_modtime
|
||||
#
|
||||
RHEL_stat)
|
||||
TZ=UTC "$STAT_TOOL" -c '%y' "$FILENAME" | sed -e 's/ /T/' -e 's/\.[0-9]* //' -e 's/\([0-9][0-9]\)$/:&/'
|
||||
status0="${PIPESTATUS[0]}"
|
||||
status1="${PIPESTATUS[1]}"
|
||||
if [[ $status0 -ne 0 || $status1 -ne 0 ]]; then
|
||||
status_codes=("${PIPESTATUS[@]}")
|
||||
if [[ ${status_codes[*]} =~ [1-9] ]]; then
|
||||
echo "$0: ERROR: in output_modtime:" \
|
||||
"TZ=UTC $STAT_TOOL -c '%y' $FILENAME | sed .. failed, error codes: $status0 and $status1" 1>&2
|
||||
"TZ=UTC $STAT_TOOL -c '%y' $FILENAME | sed .. failed," \
|
||||
"error codes: ${status_codes[*]}" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
@@ -175,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
|
||||
status_codes=("${PIPESTATUS[@]}")
|
||||
if [[ ${status_codes[*]} =~ [1-9] ]]; then
|
||||
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_TOOL -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: ${status_codes[*]}" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
+9
-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
|
||||
#
|
||||
export VERSION="1.5.4 2024-07-18"
|
||||
export VERSION="1.5.5 2024-07-18"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -178,11 +178,11 @@ function output_modtime
|
||||
#
|
||||
RHEL_stat)
|
||||
TZ=UTC "$STAT_TOOL" -c '%y' "$FILENAME" | sed -e 's/ /T/' -e 's/\.[0-9]* //' -e 's/\([0-9][0-9]\)$/:&/'
|
||||
status0="${PIPESTATUS[0]}"
|
||||
status1="${PIPESTATUS[1]}"
|
||||
if [[ $status0 -ne 0 || $status1 -ne 0 ]]; then
|
||||
status_codes=("${PIPESTATUS[@]}")
|
||||
if [[ ${status_codes[*]} =~ [1-9] ]]; then
|
||||
echo "$0: ERROR: in output_modtime:" \
|
||||
"TZ=UTC $STAT_TOOL -c '%y' $FILENAME | sed .. failed, error codes: $status0 and $status1" 1>&2
|
||||
"TZ=UTC $STAT_TOOL -c '%y' $FILENAME | sed .. failed," \
|
||||
"error codes: ${status_codes[*]}" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
@@ -194,11 +194,11 @@ function output_modtime
|
||||
# https://www.shellcheck.net/wiki/SC2012
|
||||
# shellcheck disable=SC2012
|
||||
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
|
||||
status_codes=("${PIPESTATUS[@]}")
|
||||
if [[ ${status_codes[*]} =~ [1-9] ]]; then
|
||||
echo "$0: ERROR: in output_modtime:" \
|
||||
"TZ=UTZ $LS_TOOL -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: ${status_codes[*]}" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
Reference in new issue
Block a user