From b77e5c76c28c1a07f0d0786c3c37e9a2088dfb6b Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch>
Date: Mon, 1 Nov 2021 16:21:01 +0100
Subject: [PATCH] save config diffs

---
 bin/create_config.sh | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/bin/create_config.sh b/bin/create_config.sh
index d4e5051..faf27da 100755
--- a/bin/create_config.sh
+++ b/bin/create_config.sh
@@ -128,8 +128,14 @@ if [ $? -eq 0 ]; then
 fi
 
 # --- create target file
-diff "${tmpfile}" "${outfile}" >> ${cfgdiff} 2>/dev/null
-if [ $? -eq 0 -a -f "${outfile}" ]; then
+bHasChanges=0
+if [ ! -f "${outfile}" ]; then
+    echo "File did not exist before: ${outfile} - creating it as a new file.">> ${cfgdiff} 
+    bHasChanges=1
+fi
+
+diff "${tmpfile}" "${outfile}" >> ${cfgdiff} 2>/dev/null || bHasChanges=1
+if [ $bHasChanges -eq 0 ]; then
     _warn "INFO: no changes."
 else
     mv -f "${tmpfile}" "${outfile}" || exit 4
-- 
GitLab