Fix for sort 'baulking' if $_LOG STASH contains non-existing files (because of * wildcard)

This commit is contained in:
Patrick Van der Veken 2018-04-30 13:04:37 +02:00
parent 2fd986f911
commit 862e89de12

View File

@ -105,7 +105,7 @@ then
# disclaimer # disclaimer
print "Note: this report only shows the overall combined status of all events of each HC within exactly" print "Note: this report only shows the overall combined status of all events of each HC within exactly"
print " the *same* time stamp (seconds precise). It may therefore fail to report certain FAIL IDs." print " the *same* time stamp (seconds precise). It may therefore fail to report certain FAIL IDs."
print " Use $0 --report to get the exact list of failure events." print " Use '--report' to get the exact list of failure events."
# other reports # other reports
else else
_ID_NEEDLE="[0-9][0-9]*" _ID_NEEDLE="[0-9][0-9]*"
@ -136,7 +136,9 @@ else
printf "%120s\n" | tr ' ' - printf "%120s\n" | tr ' ' -
# print failed events # print failed events
${_SORT_CMD} ${_LOG_STASH} 2>/dev/null | awk -F"${SEP}" -v id_needle="${_ID_NEEDLE}" \ # not a useless use of cat here
# (sort baulks if $_LOG STASH contains non-existing files (because of * wildcard))
cat ${_LOG_STASH} 2>/dev/null | ${_SORT_CMD} 2>/dev/null | awk -F"${SEP}" -v id_needle="${_ID_NEEDLE}" \
' '
{ {
if ($5 ~ id_needle) { if ($5 ~ id_needle) {
@ -147,7 +149,9 @@ else
printf "\n%-s\n" "SUMMARY: ${_FAIL_COUNT} failed HC event(s) found." printf "\n%-s\n" "SUMMARY: ${_FAIL_COUNT} failed HC event(s) found."
else else
# print failed events (we may have multiple events for 1 FAIL ID) # print failed events (we may have multiple events for 1 FAIL ID)
${_SORT_CMD} ${_LOG_STASH} 2>/dev/null | awk -F"${SEP}" -v id_needle="${_ID_NEEDLE}" \ # not a useless use of cat here
# (sort baulks if $_LOG STASH contains non-existing files (because of * wildcard))
cat ${_LOG_STASH} 2>/dev/null | ${_SORT_CMD} 2>/dev/null | awk -F"${SEP}" -v id_needle="${_ID_NEEDLE}" \
' BEGIN { ' BEGIN {
event_count = 1 event_count = 1
dashes = sprintf("%36s",""); gsub (/ /, "-", dashes); dashes = sprintf("%36s",""); gsub (/ /, "-", dashes);