From 6ded6169dde79d1f4b786f10c91fc984923f316b Mon Sep 17 00:00:00 2001 From: Per Cederqvist <cederp@opera.com> Date: Thu, 12 Dec 2024 11:09:17 +0100 Subject: [PATCH] Use a trap statement to simplify removal of state files --- check_lysrdiff | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/check_lysrdiff b/check_lysrdiff index b40c543..ab88e24 100755 --- a/check_lysrdiff +++ b/check_lysrdiff @@ -87,6 +87,8 @@ echo $acttime MARKER \ | sed -e '0,/MARKER$/d' \ > $state-active +trap "rm $state $state-stale $state-active" 0 + FAILED=`grep -c -- '--fail$' $state` STALE=`wc -l < $state-stale` ACTIVITY=`wc -l < $state-active` @@ -108,7 +110,6 @@ then END { if (sz >= 200) printf ", others" } ' \ |sed s'/, \([^,]*\)$/ and \1/' echo ". | $PERF" - rm $state $state-stale $state-active exit 2 fi @@ -126,7 +127,6 @@ then END { if (sz >= 200) printf ", others" } ' \ |sed s'/, \([^,]*\)$/ and \1/' echo ". | $PERF" - rm $state $state-stale $state-active exit 2 fi @@ -145,8 +145,6 @@ then END { if (sz >= 200) printf ", others" } ' \ |sed s'/, \([^,]*\)$/ and \1/' echo ". | $PERF" - rm $state $state-stale $state-active - exit 1 fi @@ -160,17 +158,14 @@ then END { if (sz >= 200) printf ", others" } ' \ |sed s'/, \([^,]*\)$/ and \1/' echo ". | $PERF" - rm $state $state-stale $state-active exit 1 fi if [ $ACTIVITY = 0 ] then echo "WARNING - No activity. | $PERF" - rm $state $state-stale $state-active exit 1 fi echo "OK - all ok. | $PERF" -rm $state $state-stale $state-active exit 0 -- GitLab