Error handling in shell scripts

main
Elbert Alias 10 years ago
parent 2c81f63146
commit ea1f3553cb

@ -7,14 +7,9 @@ then
exit 1 exit 1
fi fi
wappalyzer validate set -eu
if [ $? -ne 0 ]
then
echo "Build aborted"
exit 1 wappalyzer validate
fi
echo "Prettifying apps.json..." echo "Prettifying apps.json..."

@ -14,6 +14,8 @@ then
path=$WAPPALYZER_ROOT path=$WAPPALYZER_ROOT
fi fi
set -eu
if [ ! -d $path/src ] if [ ! -d $path/src ]
then then
echo "-$(basename $0): Incorrect path" 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/wappalyzer.js $path/drivers/npm
ln -f $path/apps.json $path/drivers/npm ln -f $path/apps.json $path/drivers/npm
echo "Done" echo "OK"
exit 0 exit 0

@ -1,9 +1,5 @@
#!/bin/bash #!/bin/bash
color_ok='\033[1;32m'
color_err='\033[0;31m'
color_none='\033[0m'
path=$1 path=$1
if [ -z $path ] if [ -z $path ]
@ -18,6 +14,8 @@ then
path=$WAPPALYZER_ROOT path=$WAPPALYZER_ROOT
fi fi
set -eu
if [ ! -d $path/src ] if [ ! -d $path/src ]
then then
echo "-$(basename $0): Incorrect path" echo "-$(basename $0): Incorrect path"
@ -29,17 +27,4 @@ path="$path/src"
echo "Validating apps.json..." echo "Validating apps.json..."
echo -en "${color_err}"
jsonlint --quiet -V $WAPPALYZER_ROOT/schema.json $path/apps.json 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

Loading…
Cancel
Save