support profiles and step aliases with spaces
This commit is contained in:
34
sequencer.sh
34
sequencer.sh
@@ -134,7 +134,7 @@ helpApi(){
|
|||||||
sequencer.sh API
|
sequencer.sh API
|
||||||
|
|
||||||
The sequencer.sh build-in functions are available in all sequence functions:
|
The sequencer.sh build-in functions are available in all sequence functions:
|
||||||
- step_config
|
- seq_config
|
||||||
If optional step_config is defined in the sequence, it will be called once before execution of steps.
|
If optional step_config is defined in the sequence, it will be called once before execution of steps.
|
||||||
- step_[1-${_sqr_stepMax}]_info
|
- step_[1-${_sqr_stepMax}]_info
|
||||||
- step_[1-${_sqr_stepMax}]_alias
|
- step_[1-${_sqr_stepMax}]_alias
|
||||||
@@ -142,14 +142,14 @@ The sequencer.sh build-in functions are available in all sequence functions:
|
|||||||
|
|
||||||
sequencer.sh global variables:
|
sequencer.sh global variables:
|
||||||
|
|
||||||
\$SEQUENCER_ARGS
|
\${sqr_args}
|
||||||
String of all given options
|
String of all given options
|
||||||
\$SEQ_CONFIG_HOME
|
\$SEQ_CONFIG_HOME
|
||||||
Path to user specific seq configuration directory
|
Path to user specific seq configuration directory
|
||||||
\$SEQ_CONFIG_FILE
|
\${seq_configFile}
|
||||||
Path to user specific seq configuration file
|
Path to user specific seq configuration file
|
||||||
Will be empty if unused
|
Will be empty if unused
|
||||||
\$SEQ_PROFILE_NAME
|
\${seq_profileName}
|
||||||
Profile string selected with -p argument
|
Profile string selected with -p argument
|
||||||
|
|
||||||
sequencer.sh build-in functions:
|
sequencer.sh build-in functions:
|
||||||
@@ -1108,8 +1108,6 @@ displayHelp() {
|
|||||||
# show only steps and aliases starting with [FILTER STRING]
|
# show only steps and aliases starting with [FILTER STRING]
|
||||||
listSteps() {
|
listSteps() {
|
||||||
local locAlias=
|
local locAlias=
|
||||||
local aList=()
|
|
||||||
local aSearch="${1:-}"
|
|
||||||
|
|
||||||
for ((i=1; i<=_sqr_stepMax; i++)); do
|
for ((i=1; i<=_sqr_stepMax; i++)); do
|
||||||
# Display step reference in help if step function exists
|
# Display step reference in help if step function exists
|
||||||
@@ -1122,14 +1120,11 @@ listSteps() {
|
|||||||
locAlias="$i"
|
locAlias="$i"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$aSearch" ]; then
|
# $1 = filter regex
|
||||||
aList+=("$locAlias")
|
if [[ "$locAlias" =~ ^${1:-.*} ]]; then
|
||||||
elif [[ "$locAlias" =~ ^$aSearch ]]; then
|
printf '%s\n' "${locAlias}"
|
||||||
aList+=("$locAlias")
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
[ ${#aList[@]} -ne 0 ] && printf '%s\n' "${aList[*]}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# listProfiles [OPTION] [SEARCH]
|
# listProfiles [OPTION] [SEARCH]
|
||||||
@@ -1138,18 +1133,15 @@ listSteps() {
|
|||||||
# -q : only check for profile support
|
# -q : only check for profile support
|
||||||
listProfiles() {
|
listProfiles() {
|
||||||
local file=
|
local file=
|
||||||
local profiles=()
|
|
||||||
if [[ ${_sqr_configDirName} == $(basename "${_sqr_configRoot}") ]] ; then
|
if [[ ${_sqr_configDirName} == $(basename "${_sqr_configRoot}") ]] ; then
|
||||||
error "${seq_name} does not have configuration profiles"
|
error "${seq_name} does not have configuration profiles"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
[[ "${1:-}" == "-q" ]] && return 0
|
[[ "${1:-}" == "-q" ]] && return 0
|
||||||
#for file in $(ls "${_sqr_configRoot}" 2>/dev/null); do
|
|
||||||
for file in "${_sqr_configRoot}"/* ; do
|
for file in "${_sqr_configRoot}"/* ; do
|
||||||
file="$(basename -- "${file}")"
|
file="$(basename -- "${file}")"
|
||||||
[[ ${file%.*} =~ ^${1:-".*"} ]] && profiles+=("${file%.*}")
|
[[ ${file%.*} =~ ^${1:-.*} ]] && printf '%s\n' "${file%.*}"
|
||||||
done
|
done
|
||||||
printf '%s\n' "${profiles[*]}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# showVersion
|
# showVersion
|
||||||
@@ -1438,6 +1430,9 @@ exep() {
|
|||||||
|
|
||||||
# Check if sequence is compatible
|
# Check if sequence is compatible
|
||||||
sqr::compatible() {
|
sqr::compatible() {
|
||||||
|
if ! exists "sqr_minVersion"; then
|
||||||
|
sqr_minVersion="${VERSION_SEQREV:-0}"
|
||||||
|
fi
|
||||||
if [ -z "${sqr_minVersion:-}" ] ; then
|
if [ -z "${sqr_minVersion:-}" ] ; then
|
||||||
warning "No sequence revision found. Trying anyway..."
|
warning "No sequence revision found. Trying anyway..."
|
||||||
else
|
else
|
||||||
@@ -1447,8 +1442,9 @@ sqr::compatible() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# exclude older versions if needed
|
# exclude older versions if needed
|
||||||
if [ -n "${sqr_minVersion}" ] && [[ ${sqr_minVersion} -lt 3 ]] ; then
|
if [ -n "${sqr_minVersion}" ] && [[ ${sqr_minVersion} -le 15 ]] ; then
|
||||||
error "Unsupported sequence revision (addConf)"
|
error "Unsupported sequence revision (major changes in version 16)"
|
||||||
|
error -a "(Use 'seqUpgrade.sh $(readlink -f -- $0)' for a basic upgrade)"
|
||||||
showVersion
|
showVersion
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@@ -1551,7 +1547,7 @@ sqr::main() {
|
|||||||
[ ${_sqr_configEdit} -ne 0 ] && [ -z "${1:-}" ] && LOG_LEVEL=1
|
[ ${_sqr_configEdit} -ne 0 ] && [ -z "${1:-}" ] && LOG_LEVEL=1
|
||||||
|
|
||||||
if [ -z "${1:-}" ] && [ $quickStartOne -eq 0 ] ; then
|
if [ -z "${1:-}" ] && [ $quickStartOne -eq 0 ] ; then
|
||||||
if ! quiet ; then
|
if ! quiet && [[ ${LOG_LEVEL} -ge $log_info ]] ; then
|
||||||
# Empty -> show help
|
# Empty -> show help
|
||||||
displayHelp
|
displayHelp
|
||||||
fi
|
fi
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
_sqn_completions()
|
_sqn_completions()
|
||||||
{
|
{
|
||||||
|
local tempreply=()
|
||||||
# Current search string
|
# Current search string
|
||||||
local cur=${COMP_WORDS[COMP_CWORD]}
|
local cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
# Extract alias command with buildins same as:
|
# Extract alias command with buildins same as:
|
||||||
@@ -35,7 +36,11 @@ _sqn_completions()
|
|||||||
# provide completion for option with parameter
|
# provide completion for option with parameter
|
||||||
-p|--profile)
|
-p|--profile)
|
||||||
# sequencer.sh provides creation of a profile list with search functionality
|
# sequencer.sh provides creation of a profile list with search functionality
|
||||||
read -r -a COMPREPLY <<<"$( "$curCmd" -pl "${cur}" 2>/dev/null)"
|
IFS=$'\n' read -r -d '' -a tempreply <<<"$( "$curCmd" -pl "${cur}" 2>/dev/null)"
|
||||||
|
for comp in "${tempreply[@]}" ; do
|
||||||
|
# Support for profile names with spaces
|
||||||
|
COMPREPLY+=("$(printf '%q' "${comp}")")
|
||||||
|
done
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# Stop after step selection (last argument which is not an option (starting with "-|+")
|
# Stop after step selection (last argument which is not an option (starting with "-|+")
|
||||||
@@ -50,7 +55,12 @@ _sqn_completions()
|
|||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
# sequencer.sh provides creation of a step list with search functionality
|
# sequencer.sh provides creation of a step list with search functionality
|
||||||
read -r -a COMPREPLY <<<"$( "$curCmd" -ls "$cur" )"
|
#read -r -a COMPREPLY <<<"$( "$curCmd" -ls "$cur" )"
|
||||||
|
IFS=$'\n' read -r -d '' -a tempreply <<<"$( "$curCmd" -ls "$cur" )"
|
||||||
|
for comp in "${tempreply[@]}" ; do
|
||||||
|
# Support for aliases with spaces
|
||||||
|
COMPREPLY+=("$(printf '%q' "${comp}")")
|
||||||
|
done
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
Reference in New Issue
Block a user