From c4be8ffcc1ad0c6f4ad5d6d6e9446f7c833155b9 Mon Sep 17 00:00:00 2001
From: "Gervaise H. Henry" <gervaise.henry@utsouthwestern.edu>
Date: Thu, 7 Jan 2021 14:20:23 -0600
Subject: [PATCH] Change error conditional in bdbag fetch to use file

---
 workflow/scripts/bdbag_fetch.sh | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/workflow/scripts/bdbag_fetch.sh b/workflow/scripts/bdbag_fetch.sh
index c29217a..c546d6f 100644
--- a/workflow/scripts/bdbag_fetch.sh
+++ b/workflow/scripts/bdbag_fetch.sh
@@ -1,19 +1,20 @@
 #!/bin/bash
 
 bdbag --materialize ${1} --debug
-validateError="true"
-bdbag --validate full ${1} && validateError="false"
-if [ "${validateError}" == "true" ]
+validate=""
+bdbag --validate full ${1} 2> validate.txt
+validate=$(tail -n validate.txt | grep -o 'is valid')
+if [ "${validate}" != "is valid" ]
 then
     n=0
     until [ "${n}" -ge "3" ]
     do
-        bdbag --resolve-fetch missing --validate full ${1} --debug && validateError="false" && break
+        bdbag --resolve-fetch missing --validate full ${1} --debug && validate=$(tail -n validate.txt | grep -o 'is valid') && break
         n=$((n+1)) 
         sleep 15
     done
 fi
-if [ "${validateError}" == "true" ]
+if [ "${validate}" != "is valid" ]
 then
     exit 1
 fi
-- 
GitLab