Skip to content

Commit

Permalink
Handle empty log directory correctly in 'log' command.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfeit-internet2 committed Jun 24, 2024
1 parent ce3d6e1 commit b95b7b7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pscheduler-server/pscheduler-server/utilities/log.raw
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ LOGBASE="__LOGFILE__"

if [ $# -eq 0 ]
then
exec cat "${LOGDIR}/${LOGBASE}"
LATEST_LOG="${LOGDIR}/${LOGBASE}"
if [ -s "${LATEST_LOG}" ]
then
exec cat "${LATEST_LOG}"
fi
elif [ "$1" = "--all" ]
then
# PORT: xargs -r is non-POSIX
find "${LOGDIR}" -type f -name "${LOGBASE}*" -print0 \
| xargs -0 ls -htr \
| xargs -r -0 ls -htr \
| tr "\n" "\0" \
| xargs -0 cat
| xargs -r -0 cat
else
echo "Usage: $(basename "$0") [ --all ]"
exit 1
Expand Down

0 comments on commit b95b7b7

Please sign in to comment.