From ea1f3553cb644181761fd6fc262fb4a76d011c37 Mon Sep 17 00:00:00 2001 From: Elbert Alias Date: Thu, 26 Feb 2015 08:08:51 +1100 Subject: [PATCH] Error handling in shell scripts --- bin/wappalyzer-build | 9 ++------- bin/wappalyzer-links | 4 +++- bin/wappalyzer-validate | 19 ++----------------- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/bin/wappalyzer-build b/bin/wappalyzer-build index 686134a10..331ff06d4 100755 --- a/bin/wappalyzer-build +++ b/bin/wappalyzer-build @@ -7,14 +7,9 @@ then exit 1 fi -wappalyzer validate - -if [ $? -ne 0 ] -then - echo "Build aborted" +set -eu - exit 1 -fi +wappalyzer validate echo "Prettifying apps.json..." diff --git a/bin/wappalyzer-links b/bin/wappalyzer-links index babe567fd..ade71074b 100755 --- a/bin/wappalyzer-links +++ b/bin/wappalyzer-links @@ -14,6 +14,8 @@ then path=$WAPPALYZER_ROOT fi +set -eu + if [ ! -d $path/src ] then echo "-$(basename $0): Incorrect path" @@ -55,6 +57,6 @@ ln -f $path/apps.json $path/drivers/ruby ln -f $path/wappalyzer.js $path/drivers/npm ln -f $path/apps.json $path/drivers/npm -echo "Done" +echo "OK" exit 0 diff --git a/bin/wappalyzer-validate b/bin/wappalyzer-validate index df05aeb83..cb91bc240 100755 --- a/bin/wappalyzer-validate +++ b/bin/wappalyzer-validate @@ -1,9 +1,5 @@ #!/bin/bash -color_ok='\033[1;32m' -color_err='\033[0;31m' -color_none='\033[0m' - path=$1 if [ -z $path ] @@ -18,6 +14,8 @@ then path=$WAPPALYZER_ROOT fi +set -eu + if [ ! -d $path/src ] then echo "-$(basename $0): Incorrect path" @@ -29,17 +27,4 @@ path="$path/src" echo "Validating apps.json..." -echo -en "${color_err}" - jsonlint --quiet -V $WAPPALYZER_ROOT/schema.json $path/apps.json - -if [ $? -eq 0 ] -then - echo -e "${color_ok}Ok${color_none}" - - exit 0 -else - echo -en "${color_none}" - - exit 1 -fi