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