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:
@@ -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
|
||||
|
Reference in New Issue
Block a user