#!/bin/bash# VariablesSUB_SCRIPTS=" \ a.sh \ b.sh \"# Functionsfunction cmdExists() { if [ ! -e $1 ]; then return 1; else return 0; fi}function hasPermToExec() { if [ ! -x $1 ]; then return 1; else return 0; fi}function executeScript() { sh $1; return $?;}# first parameter is the error descriptionfunction reportErrorAndExit() { echo "Error: $1"; exit 1;}# Execution starts herefor i in $(echo $SUB_SCRIPTS | xargs); do # Check if command exists cmdExists $i if [ "$?" -ne 0 ]; then reportErrorAndExit "Script $i not found"; fi # Check if the user has permission to execute script hasPermToExec $i if [ "$?" -ne 0 ]; then reportErrorAndExit "No permissions to execute script $i"; fi # Execute Script and check return value executeScript $i if [ "$?" -ne 0 ]; then reportErrorAndExit "Script $i exited with an error"; fidone;