From 1a37034c514fd3c131a1060b9a0802e1d0897538 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 9 Jul 2024 18:45:34 +0000 Subject: [PATCH] Don't spuriously error printing drop counts when there are no rules --- dropcount.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dropcount.sh b/dropcount.sh index 6278955..6960ef9 100755 --- a/dropcount.sh +++ b/dropcount.sh @@ -34,8 +34,10 @@ echo "$MAP_CONTENTS" | { echo -e "${PACKETS[2]}\t$(( ${BYTES[2]} / 1000 ))\tInvalid/rejected IHL IPv4 field" echo -e "${PACKETS[3]}\t$(( ${BYTES[3]} / 1000 ))\tRejected IPv6 fragments" C=4 - while read LINE; do - echo -e "${PACKETS["$C"]}\t$(( ${BYTES["$C"]} / 1000 ))\t$LINE" - C=$(( $C + 1 )) - done < "$(dirname ${BASH_SOURCE[0]})/installed-rules.txt" + if [ "$(wc -l "$(dirname ${BASH_SOURCE[0]})/installed-rules.txt")" != "0" ]; then + while read LINE; do + echo -e "${PACKETS["$C"]}\t$(( ${BYTES["$C"]} / 1000 ))\t$LINE" + C=$(( $C + 1 )) + done < "$(dirname ${BASH_SOURCE[0]})/installed-rules.txt" + fi } -- 2.39.5