diff --git a/sequencer/sequencer.sh b/sequencer/sequencer.sh index c33e9f9..3c5c76d 100755 --- a/sequencer/sequencer.sh +++ b/sequencer/sequencer.sh @@ -6,7 +6,7 @@ ## Version information -VERSION_REV=5 +VERSION_REV=6 VERSION_MAJOR=0 VERSION_MINOR=0 @@ -76,26 +76,56 @@ saveReturn() { fi } -# endReturn [-f] -# -f : force exit with $ERNO without user input +# endReturn [-f] [MESSAGE] +# -f : force exit with $ERNO without user input +# MESSAGE : Custom error message +# endReturn() { - if [[ ( $ERNO -ne 0 && $QUIET -ne 0 ) || ( $ERNO -ne 0 && ! -z $1 && $1 == "-f" ) ]] ; then + local forceExit=0 + local endMessage="" + + for arg in "$@" ; do + case "$1" in + -f) + forceExit=1 + skipStep=0 + shift + ;; + "") + break + ;; + *) + endMessage="$@" + break + ;; + esac + done + + if [[ ( $ERNO -ne 0 && $QUIET -ne 0 ) || ( $ERNO -ne 0 && $forceExit -ne 0 ) ]] ; then echo - echo -e " [E] Return value $ERNO detected.\nAborting installation." + if [ "$endMessage" != "" ]; then + echo -e " [E] $endMessage" + else + echo -e " [E] Return value $ERNO detected.\n Aborting installation." + fi exit $ERNO fi if [ $ERNO -ne 0 ] ; then echo - echo " [E] Return value $ERNO detected." + if [ "$endMessage" != "" ]; then + echo -e " [W] $endMessage" + else + echo " [W] Return value $ERNO detected." + fi read -p "End installation: [y]/n? " answer case $answer in [nN]) echo - echo Continuing installation... + echo " [I] Continuing installation..." ;; *) echo - echo Installation aborted + echo " [E] Installation aborted" exit $ERNO; ;; esac @@ -355,7 +385,7 @@ displayHelp() { fi stepsFound=1 done - + if [ $stepsFound -eq 0 ] ; then echo -e "\n It seems ${0##*/} was called directly." echo -e " Please create a sequence script first.\n"