From 3dc755cd833e9c1f802cbec986a23707129f7825 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Riette?= <sebastien.riette@meteo.fr>
Date: Fri, 15 Apr 2022 15:48:39 +0200
Subject: [PATCH] Check for file existence before trying to compare them

---
 check_commit_mesonh.sh | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/check_commit_mesonh.sh b/check_commit_mesonh.sh
index 274c90548..6caea45b9 100755
--- a/check_commit_mesonh.sh
+++ b/check_commit_mesonh.sh
@@ -289,11 +289,17 @@ if [ $check -eq 1 ]; then
       file1=$path_user/16JAN.1.12B18.001.nc 
       file2=$path_ref/16JAN.1.12B18.001.nc
       echo "Compare with ncdump..."
-      set +e
-      diff <(ncdump $file1 | head -c 62889) <(ncdump $file2 | head -c 62889)
-      t=$?
-      set -e
-      allt=$(($allt+$t))
+      if [ -f $file1 -a -f $file2 ]; then
+        set +e
+        diff <(ncdump $file1 | head -c 62889) <(ncdump $file2 | head -c 62889)
+        t=$?
+        set -e
+        allt=$(($allt+$t))
+      else
+        [ ! -f $file1 ] && echo "  $file1 is missing"
+        [ ! -f $file2 ] && echo "  $file2 is missing"
+        allt=$(($allt+1))
+      fi
     fi
   done
 
-- 
GitLab