From 30ea5e8a3877713e225de8f4442301bf8bd56de6 Mon Sep 17 00:00:00 2001
From: Andreas Romeyke <art1@andreas-romeyke.de>
Date: Thu, 13 Oct 2022 18:18:02 +0200
Subject: [PATCH] - protect script for STRG-C, closes
 https://git.slub-dresden.de/digital-preservation/validate_workflows/-/issues/4

---
 validate_workflow.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/validate_workflow.sh b/validate_workflow.sh
index 52e230e..6b2b5e6 100755
--- a/validate_workflow.sh
+++ b/validate_workflow.sh
@@ -414,6 +414,8 @@ scan_file() {
         # try best guess
         MODE=$(estimate_mode "$mimetype")
     fi
+    trap "" SIGINT
+    debug "scan_file, === entering protected area ==="
     if [ "$STAGE" = "any" ]; then
         is_valid=0
         for stage in current upcoming; do
@@ -429,7 +431,9 @@ scan_file() {
         is_valid=$(exec_cmd "$cmd" "$ftype" "$MODE" "$stage" "$logname")
         handle_input_if_requested "$filename" "$is_valid"
     fi
-
+    debug "scan_file, === leaving protected area ==="
+    trap - SIGINT
+    debug "---"
 }
 
 scan_dir() {
@@ -441,6 +445,7 @@ done
 #### MAIN
 
 get_cli_args "$@"
+#trap signalhandler SIGINT SIGABRT #sigint
 if [ "$WITH_PIPE" -eq 1 ]; then
     #cli mode, use stdin
     debug "checking stream"
-- 
GitLab