Fix running step_config if first step is invalid

sequencer.sh now returns with last result
This commit is contained in:
2020-01-13 17:18:11 +01:00
parent 31b85395d6
commit a657473871

View File

@@ -162,9 +162,17 @@ helpApi() {
echoerr() { >&2 echo "$@"; }
# Echo additional line to info correctly indented
HELPINDENT=' : '
HELPINDENTAPPEND=' '
echoinfo() { printf '%s' "$HELPINDENTAPPEND"; echo "$@"; }
CONTEXT_HELP=0
INDENT_HELP=' : '
INDENTAPPEND_HELP=' '
INDENTAPPEND_INFO=' '
echoinfo() {
if [ $CONTEXT_HELP -ne 0 ] ; then
printf '%s' "$INDENTAPPEND_HELP"; echo "$@"
else
printf '%s' "$INDENTAPPEND_INFO"; echo "$@"
fi
}
# endCheckEmpty <VariableName> [DESCRIPTION]
# DESCRIPTION : Optional text for error
@@ -520,6 +528,7 @@ execute() {
# checkStep <Step Number or Alias>
# return 0 - for invalid step
# return Step Number
# Check sanitiy of step number or
# Check if alias exists
checkStep() {
@@ -680,6 +689,7 @@ parseAlias() {
# Always display sequencer help and, if available, sequence help
displayHelp() {
local stepsFound=0
CONTEXT_HELP=1
helpSequencer
# check if step definition exists by looking for a step_*() function
@@ -725,7 +735,7 @@ displayHelp() {
if [ $? -eq 0 ] ; then
step_${i}_alias
echo " = $ALIAS"
printf '%s' "$HELPINDENT"
printf '%s' "$INDENT_HELP"
else
echo -n " : "
fi
@@ -740,6 +750,7 @@ displayHelp() {
done
echo
fi
CONTEXT_HELP=0
}
# showVersion
@@ -866,11 +877,16 @@ main() {
parseAlias
# run configuration for seq if available
# run configuration for seq only if available and if first step is valid
existsFunction step_config
if [ $? -eq 0 ] ; then
checkStep "${START[0]}"
if [ $? -ne 0 ] ; then
echo " [I] Configuring sequence (step_config) ..."
step_config
else
return 1
fi
fi
# check if more than one step is given and select execution mode
@@ -881,12 +897,14 @@ main() {
else
continous $START
fi
if [ $QUIET -ne 2 ] ; then
echo
echo "${0##*/} finished"
fi
}
main "$@"
exit 0;
MAINRETURN=$?
if [ $QUIET -ne 2 ] ; then
echo
echo "${0##*/} finished"
fi
exit $MAINRETURN;