support multiple shell arguments (e.g. -v -q)

new verbose output (-v) to echo commands called with exe() before execution
This commit is contained in:
2019-04-10 11:12:28 +01:00
parent a124608e36
commit 3b23840277
2 changed files with 45 additions and 25 deletions

View File

@@ -13,7 +13,7 @@
step_1_info() { echo "Step $1 header"; }
step_1_alias() { ALIAS="begin"; }
step_1() {
cat .nofile
exe cat '.no f"le'
saveReturn $?
}

View File

@@ -13,6 +13,7 @@ VERSION_MINOR=0
## Start of generic script part
QUIET=0
VERBOSE=0
ERNO=0
MAX_STEP=255
ALIAS=
@@ -24,10 +25,12 @@ helpSequencer() {
echo "Usage: ${0##*/} [OPTIONS] [STEP NUMBER(s) or ALIAS]"
echo
echo " [OPTIONS]"
echo " --help, -h : Display help"
echo " --quiet, -q : Don't ask for permission to execute steps"
echo " If called without starting step number, only this help is shown"
echo " --version,-v : Display version of sequencer and revision of sequence"
echo " --help, -h : Display help"
echo " --quiet, -q : Don't ask for permission to execute steps"
echo " If called without starting step number, only this help is shown"
echo " --verbose, -v : Verbose output (use exe() function to call shell commands in seqs)"
echo " ( e.g.: exe apt update )"
echo " --version : Display version of sequencer and revision of sequence"
echo
echo " [STEP NUMBER(s) 1-${MAX_STEP} or ALIAS]"
echo " Single STEP or ALIAS : starting point of process"
@@ -331,29 +334,46 @@ showVersion() {
fi
}
exe() {
arr=("$@")
if [ $VERBOSE -eq 1 ] ; then
(set -x; "${arr[@]}")
else
"${arr[@]}"
fi
}
main() {
local START=0
# option check
case "$1" in
--help|-h) # show only help
displayHelp
exit 0;
;;
--quiet|-q) # detect if option quiet is available
QUIET=1
shift
;;
--version|-v) # version request
showVersion
exit 0;
;;
"") # Empty -> show help
displayHelp
# Assume starting at one for interactive mode
START=1
;;
esac
# options check
for arg in "$@" ; do
case "$arg" in
--help|-h) # show only help
displayHelp
exit 0;
;;
--quiet|-q) # detect if option quiet is available
QUIET=1
shift
;;
--verbose|-v) # set verbose flag
VERBOSE=1
shift
;;
--version) # version request
showVersion
exit 0;
;;
esac
done
if [ -z $1 ] || [ "$1" == "" ] ; then
# Empty -> show help
displayHelp
# Assume starting at one for interactive mode
START=1
fi
# compatibility check of sequence
if [ ! -z $VERSION_SEQREV ] && [ $VERSION_SEQREV -gt $VERSION_REV ] ; then