Work around some bugs in bash 5.2 by bouncing some data though variables.
This commit is contained in:
parent
31288bc429
commit
8202a2563b
1 changed files with 13 additions and 7 deletions
20
lumberjack
20
lumberjack
|
|
@ -567,7 +567,7 @@ TEMPLATE="$2"
|
||||||
# Main loop
|
# Main loop
|
||||||
while :; do
|
while :; do
|
||||||
# Reset used variables.
|
# Reset used variables.
|
||||||
unset LOG_VHOST LOG_DATA
|
unset LOG_VHOST LOG_DATA LINE
|
||||||
FLAGS[timed-out]=0
|
FLAGS[timed-out]=0
|
||||||
|
|
||||||
# Start compression jobs if there's any in the queue.
|
# Start compression jobs if there's any in the queue.
|
||||||
|
|
@ -577,10 +577,7 @@ while :; do
|
||||||
(( DEBUG == 1 )) && printf "%s: %s\\n" "$(date "+%Y%m%d %H%M%S.%N")" "enter read" >>"$DEBUG_FILE"
|
(( DEBUG == 1 )) && printf "%s: %s\\n" "$(date "+%Y%m%d %H%M%S.%N")" "enter read" >>"$DEBUG_FILE"
|
||||||
|
|
||||||
# Read the log line, but timeout at the top of the next second if nothing is read.
|
# Read the log line, but timeout at the top of the next second if nothing is read.
|
||||||
# Note: The second $(...) expansion should *not* be quoted in this instance, and
|
read -r -t "0.$(( 999999999 - 10#$(date +%N) ))" -u "$INPUTFD" LINE
|
||||||
# the space between $( and (( is necessary to quiet shellcheck.
|
|
||||||
# shellcheck disable=SC2046
|
|
||||||
read -r -t "0.$(( 999999999 - 10#$(date +%N) ))" -u "$INPUTFD" $( (( FLAGS[raw] == 0 )) && printf "%s" "LOG_VHOST") LOG_DATA
|
|
||||||
ERR="$?"
|
ERR="$?"
|
||||||
|
|
||||||
# If debugging, record the time of exit from read.
|
# If debugging, record the time of exit from read.
|
||||||
|
|
@ -630,6 +627,14 @@ while :; do
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Extract the data from the read line.
|
||||||
|
if (( FLAGS[raw] == 0 )); then
|
||||||
|
LOG_VHOST="${LINE%% *}"
|
||||||
|
LOG_DATA="${LINE#* }"
|
||||||
|
else
|
||||||
|
LOG_DATA="$LINE"
|
||||||
|
fi
|
||||||
|
|
||||||
# Expand the strftime-encoded strings in the template.
|
# Expand the strftime-encoded strings in the template.
|
||||||
EXPANDED_TEMPLATE="$(printf "%($TEMPLATE)T")"
|
EXPANDED_TEMPLATE="$(printf "%($TEMPLATE)T")"
|
||||||
|
|
||||||
|
|
@ -741,8 +746,9 @@ while :; do
|
||||||
# Create symlink to the currently active log file.
|
# Create symlink to the currently active log file.
|
||||||
[[ "$LINKFILE" ]] && {
|
[[ "$LINKFILE" ]] && {
|
||||||
LINKFILE_EXPANDED="$(printf "%($LINKFILE)T")"
|
LINKFILE_EXPANDED="$(printf "%($LINKFILE)T")"
|
||||||
[[ "$(stat -L --printf="%d:%i" "$BASEDIR/${LINKFILE_EXPANDED//\{\}/$LOG_VHOST}" 2>/dev/null)" != \
|
STAT1="$(stat -L --printf="%d:%i" "$BASEDIR/${LINKFILE_EXPANDED//\{\}/$LOG_VHOST}" 2>/dev/null)"
|
||||||
"$(stat --printf="%d:%i" "$FILENAME" 2>/dev/null)" ]] && {
|
STAT2="$(stat --printf="%d:%i" "$FILENAME" 2>/dev/null)"
|
||||||
|
[[ "$STAT1" != "$STAT2" ]] && {
|
||||||
# Note: This will clobber anything that already exists with the link name.
|
# Note: This will clobber anything that already exists with the link name.
|
||||||
rm -rf "${BASEDIR:?}/${LINKFILE_EXPANDED//\{\}/$LOG_VHOST}"
|
rm -rf "${BASEDIR:?}/${LINKFILE_EXPANDED//\{\}/$LOG_VHOST}"
|
||||||
if ! ln -sfr "$FILENAME" "$BASEDIR/${LINKFILE_EXPANDED//\{\}/$LOG_VHOST}" 2>/dev/null; then
|
if ! ln -sfr "$FILENAME" "$BASEDIR/${LINKFILE_EXPANDED//\{\}/$LOG_VHOST}" 2>/dev/null; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue