New option -qq to suppress regular output

Usefull when step are called from another seq
This commit is contained in:
2020-01-05 15:04:20 +01:00
parent 8d303bbcbc
commit 2e6984aac8

View File

@@ -8,7 +8,7 @@
## Version information ## Version information
VERSION_REV=9 VERSION_REV=9
VERSION_MAJOR=1 VERSION_MAJOR=2
VERSION_MINOR=0 VERSION_MINOR=0
## Start of generic script part ## Start of generic script part
@@ -36,6 +36,7 @@ helpSequencer() {
echo " (e.g. exe,addconf,echerr,...)" echo " (e.g. exe,addconf,echerr,...)"
echo " --quiet, -q : Don't ask for permission to execute steps" echo " --quiet, -q : Don't ask for permission to execute steps"
echo " If called without starting step number, only this help is shown" echo " If called without starting step number, only this help is shown"
echo " -qq : Same as --quiet but suppresses regular sequencer.sh output"
echo " --single, -s : Execute only one step" echo " --single, -s : Execute only one step"
echo " If more than one step is requested, only the first will be executed" echo " If more than one step is requested, only the first will be executed"
echo " --verbose, -v : Verbose output (use exe() function to call shell commands in seqs)" echo " --verbose, -v : Verbose output (use exe() function to call shell commands in seqs)"
@@ -64,6 +65,16 @@ helpApi() {
echo "- step_[1-${MAX_STEP}]_alias" echo "- step_[1-${MAX_STEP}]_alias"
echo "- step_[1-${MAX_STEP}]" echo "- step_[1-${MAX_STEP}]"
echo echo
echo "sequencer.sh global variables:"
echo
echo " \$QUIET"
echo " 0 : default"
echo " 1 (-q) : No user interaction (e.g. question to start a step)"
echo " 2 (-qq) : 1 and no regular output of sequencer.sh"
echo " \$DRY"
echo " 0 : default"
echo " 1 (-d) : Commands shall only be printed but not executed"
echo
echo "sequencer.sh build-in functions:" echo "sequencer.sh build-in functions:"
echo echo
echo " exe [COMMANDLINE]" echo " exe [COMMANDLINE]"
@@ -376,15 +387,18 @@ execute() {
return $NOTFOUND return $NOTFOUND
fi fi
echo -en "\n [STEP $1] " if [ $QUIET -ne 2 ] ; then
existsFunction step_${1}_info echo -en "\n [STEP $1] "
if [ $? -eq 0 ] ; then existsFunction step_${1}_info
step_${1}_info $1 "${STEP_ARGS[@]}" if [ $? -eq 0 ] ; then
else step_${1}_info $1 "${STEP_ARGS[@]}"
# Add newline if no info is given else
echo # Add newline if no info is given
echo
fi
fi fi
if [ $QUIET -ne 1 ] ; then
if [ $QUIET -eq 0 ] ; then
read -p "Start: (y)es/[n]o/(s)kip? " answer read -p "Start: (y)es/[n]o/(s)kip? " answer
case $answer in case $answer in
[yY]) [yY])
@@ -469,8 +483,8 @@ continous() {
if [[ $step == 0 ]] ; then if [[ $step == 0 ]] ; then
return 1 return 1
fi fi
echo " [I] Staring sequence $(realpath $0) ..." if [ $QUIET -ne 2 ]; then echo " [I] Starting sequence $(realpath $0) ..."; fi
for ((i=$step; i<=${MAX_STEP}; i++)); do for ((i=$step; i<=${MAX_STEP}; i++)); do
execute -q $i execute -q $i
@@ -492,7 +506,7 @@ selection() {
return 1 return 1
fi fi
echo " [I] Staring sequence $(realpath $0) ..." if [ $QUIET -ne 2 ]; then echo " [I] Starting sequence $(realpath $0) ..."; fi
for i in ${array[@]} ; do for i in ${array[@]} ; do
checkStep "$i" checkStep "$i"
@@ -685,8 +699,12 @@ main() {
helpApi helpApi
exit 0; exit 0;
;; ;;
--quiet|-q) # detect if option quiet is available --quiet|-q|-qq) # detect if option quiet is available
QUIET=1 if [ "$1" == "-qq" ] ; then
QUIET=2
else
QUIET=1
fi
shift shift
;; ;;
--single|-s) # execute only one step and stop --single|-s) # execute only one step and stop
@@ -733,7 +751,7 @@ main() {
fi fi
# End here on quiet mode and no step was given # End here on quiet mode and no step was given
if [ $EMPTYCALL -ne 0 ] && [ $QUIET -eq 1 ] ; then if [ $EMPTYCALL -ne 0 ] && [ $QUIET -ne 0 ] ; then
exit 1; exit 1;
fi fi
@@ -763,8 +781,10 @@ main() {
continous $START continous $START
fi fi
echo if [ $QUIET -ne 2 ] ; then
echo "${0##*/} finished" echo
echo "${0##*/} finished"
fi
} }
main "$@" main "$@"