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