From 77d9f61de0aa8c14bd14f289fdf0c46dcb384c5a Mon Sep 17 00:00:00 2001 From: JustAnotherArchivist Date: Sat, 7 Nov 2020 00:32:51 +0000 Subject: [PATCH] Colourise output --- iasha1check | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/iasha1check b/iasha1check index 2748b8a..790d174 100755 --- a/iasha1check +++ b/iasha1check @@ -15,9 +15,15 @@ readarray -t iaMissing < <(comm -23 <(printf "%s\n" "${localFilesSorted[@]}") <( status=0 +RED=$'\x1b[1;31m' +GREEN=$'\x1b[0;32m' +RESET=$'\x1b[0m' + if [[ ${#localMissing[@]} -eq 0 && ${#iaMissing[@]} -eq 0 ]] then - echo "File list comparison: OK" + echo "File list comparison: ${GREEN}OK${RESET}" +else + echo "File list comparison: ${RED}FAIL${RESET}" fi if [[ ${#iaMissing[@]} -gt 0 ]] then @@ -32,12 +38,24 @@ then status=1 fi +echo + echo "SHA-1 comparison:" sha1sum -c < <(printf "%s\n" "${iasha1sums[@]}") > >(sed 's,^, ,') 2>&1 -if [[ $? -ne 0 ]] +if [[ $? -eq 0 ]] then - echo "SHA-1 comparison failed!" + echo "SHA-1 comparison: ${GREEN}OK${RESET}" +else + echo "SHA-1 comparison: ${RED}FAIL${RESET}" status=1 fi +echo + +if [[ ${status} -eq 0 ]] +then + echo "${GREEN}OK${RESET}" +else + echo "${RED}FAIL${RESET}" +fi exit ${status}