Refactor simple internal variables so that overrides from sequences get more unlicely

This commit is contained in:
2021-04-13 10:09:37 +02:00
parent b8586cfc7c
commit b2a851c4af

View File

@@ -9,7 +9,7 @@
VERSION_REV=13 VERSION_REV=13
VERSION_MAJOR=1 VERSION_MAJOR=1
VERSION_MINOR=0 VERSION_MINOR=1
## Start of generic script part ## Start of generic script part
@@ -730,30 +730,30 @@ execute() {
# Check sanitiy of step number or # Check sanitiy of step number or
# Check if alias exists # Check if alias exists
checkStep() { checkStep() {
local rex='^[0-9]+$' local checkStep_rex='^[0-9]+$'
local ref="" local checkStep_ref=""
# Check if string is a number or alias # Check if string is a number or alias
if ! [[ "$1" =~ $rex ]] ; then if ! [[ "$1" =~ $checkStep_rex ]] ; then
eval 'ref=$alias_'"$1" eval 'checkStep_ref=$alias_'"$1"
# Catch special character after eval # Catch special character after eval
if ! [[ "$ref" =~ $rex ]] ; then if ! [[ "$checkStep_ref" =~ $checkStep_rex ]] ; then
ref=0 checkStep_ref=0
fi fi
else else
ref=$1 checkStep_ref=$1
fi fi
if (( $ref < 1 || $ref > $MAX_STEP )) ; then if (( $checkStep_ref < 1 || $checkStep_ref > $MAX_STEP )) ; then
echoerr " [E] Invalid step: $ref" echoerr " [E] Invalid step: $1"
return 0 return 0
else else
existsFunction step_$ref existsFunction step_$checkStep_ref
if [ $? -eq 0 ] ; then if [ $? -eq 0 ] ; then
return $ref return $checkStep_ref
else else
# step doesn't exist # step doesn't exist
echoerr " [E] Invalid step: $ref" echoerr " [E] Invalid step: $1"
return 0 return 0
fi fi
fi fi
@@ -779,26 +779,19 @@ step() {
# (max $MAX_STEP) # (max $MAX_STEP)
# execute sequence continously from given starting step # execute sequence continously from given starting step
continous() { continous() {
local i local continous_i
local step=0 local continous_step=0
checkStep "$1" checkStep "$1"
step=$? continous_step=$?
if [[ $step == 0 ]] ; then [[ $continous_step == 0 ]] && return 1
return 1
fi
if [ $QUIET -ne 2 ]; then echo " [I] Starting sequence $(realpath $0) ..."; fi echoseq " [I] Starting sequence $(realpath $0) ..."
for ((i=$step; i<=${MAX_STEP}; i++)); do for ((continous_i=$continous_step; continous_i<=${MAX_STEP}; continous_i++)); do
execute -q $i execute -q $continous_i
local res=$? [ $? -ne 0 ] && break
if [ $res -ne 0 ] ; then [ $STEP_RETURN -ne 0 ] && break
break
fi
if [ $STEP_RETURN -ne 0 ] ; then
break
fi
done done
return $STEP_RETURN return $STEP_RETURN
} }
@@ -807,23 +800,21 @@ continous() {
# execute given step list # execute given step list
# e.g.: selection -q (1, 4, 12) # e.g.: selection -q (1, 4, 12)
selection() { selection() {
local i local selection_i
local step=0 local selection_step=0
local array=("$@") local selection_array=("$@")
if [ ${#array[@]} -eq 0 ] ; then [ ${#selection_array[@]} -eq 0 ] && return 1
return 1
fi
if [ $QUIET -ne 2 ]; then echo " [I] Starting sequence $(realpath $0) ..."; fi echoseq " [I] Starting sequence $(realpath $0) ..."
for i in ${array[@]} ; do for selection_i in ${selection_array[@]} ; do
checkStep "$i" checkStep "$selection_i"
step=$? selection_step=$?
if [ $step -eq 0 ] ; then if [ $selection_step -eq 0 ] ; then
return 1 return 1
else else
execute $step execute $selection_step
fi fi
done done
return $STEP_RETURN return $STEP_RETURN