cleanup + fix shellcheck warnings
This commit is contained in:
parent
794213ecd5
commit
c11f6cd396
19
helper.sh
19
helper.sh
@ -8,6 +8,7 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
|||||||
_get_heighest \
|
_get_heighest \
|
||||||
_default_sort \
|
_default_sort \
|
||||||
_etools_print_assoc_array \
|
_etools_print_assoc_array \
|
||||||
|
_debug_time \
|
||||||
_filter;
|
_filter;
|
||||||
do
|
do
|
||||||
unset $function || echo "failed to unset function: $function"
|
unset $function || echo "failed to unset function: $function"
|
||||||
@ -33,7 +34,9 @@ function _formatted_find() {
|
|||||||
|
|
||||||
function _set_weights() {
|
function _set_weights() {
|
||||||
for package in "${!_etools_packages[@]}"; do
|
for package in "${!_etools_packages[@]}"; do
|
||||||
for regex in ${!package_weights[@]}; do
|
# allow reference to sourced value
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
for regex in "${!package_weights[@]}"; do
|
||||||
if [[ $package =~ ^*${regex}*$ ]]; then
|
if [[ $package =~ ^*${regex}*$ ]]; then
|
||||||
_etools_packages[$package]=${package_weights[$regex]}
|
_etools_packages[$package]=${package_weights[$regex]}
|
||||||
fi
|
fi
|
||||||
@ -42,7 +45,6 @@ function _set_weights() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _get_heighest() {
|
function _get_heighest() {
|
||||||
# declare -n _etools_packages=$1
|
|
||||||
local max_key=""
|
local max_key=""
|
||||||
local max_value=-100
|
local max_value=-100
|
||||||
|
|
||||||
@ -72,8 +74,9 @@ function _etools_print_assoc_array {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _debug_time() {
|
function _debug_time() {
|
||||||
local end_time=$(date +%s%3N)
|
local end_time=
|
||||||
echo $((end_time - start_time))
|
end_time=$(date +%s%3N)
|
||||||
|
echo $((end_time - $1))
|
||||||
}
|
}
|
||||||
|
|
||||||
function _filter() {
|
function _filter() {
|
||||||
@ -82,12 +85,10 @@ function _filter() {
|
|||||||
(( $# <= 1 )) && ewarn "No packages found, review config options" && return 1;
|
(( $# <= 1 )) && ewarn "No packages found, review config options" && return 1;
|
||||||
declare -Ag _etools_packages
|
declare -Ag _etools_packages
|
||||||
for package in "$@"; do
|
for package in "$@"; do
|
||||||
# allow indirect reference
|
|
||||||
# shellcheck disable=SC2034
|
|
||||||
package=${package//\"/}
|
package=${package//\"/}
|
||||||
base_name="${package##*/}" # Get the last part
|
base_name="${package##*/}"
|
||||||
parent_name="${package%/*}" # Remove the last part
|
parent_name="${package%/*}"
|
||||||
parent_name="${parent_name##*/}" # Get the second-to-last part
|
parent_name="${parent_name##*/}"
|
||||||
_etools_packages["$parent_name/$base_name"]=0
|
_etools_packages["$parent_name/$base_name"]=0
|
||||||
done
|
done
|
||||||
local functions=
|
local functions=
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user