Use outer array in filterModules

This commit is contained in:
Rezart Qelibari
2022-02-04 14:58:17 +01:00
parent 9feb138b39
commit 88e71a3fe5
3 changed files with 34 additions and 34 deletions

View File

@@ -15,20 +15,20 @@ function autoloadZShLib() {
autoload -Uz "${funcNames[@]}"
}
function getFilteredModules() {
function filterModules() {
if [ "${#module}" -eq 0 ]; then
echo "${allModules[@]}"
modulesToInstall=("${allModules[@]}")
else
local mod modulesToKeep=()
local mod
modulesToInstall=()
for mod in "${allModules[@]}"; do
local foundAtIndex="${module[(Ie)${mod}]}"
if [ "${inverse}" != 'true' -a "${foundAtIndex}" -gt 0 ]; then
modulesToKeep+=("${mod}")
modulesToInstall+=("${mod}")
elif [ "${inverse}" = 'true' -a "${foundAtIndex}" -eq 0 ]; then
modulesToKeep+=("${mod}")
modulesToInstall+=("${mod}")
fi
done
echo "${modulesToKeep[@]}"
fi
}
@@ -170,8 +170,8 @@ function main() {
Copyright (C) 2022 Rezart Qelibari, Astzweig GmbH & Co. KG
License EUPL-1.2. There is NO WARRANTY, to the extent permitted by law.
USAGE`"
local allModules=("${(f)$(find ./modules -type f -perm +u=x -maxdepth 1 2> /dev/null | awk -F/ '{print $NF }' | sort -n)}")
local modulesToInstall=(`getFilteredModules`)
local allModules=("${(f)$(find ./modules -type f -perm +u=x -maxdepth 1 2> /dev/null | awk -F/ '{print $NF }' | sort -n)}") modulesToInstall
filterModules
ensureDocopts
autoloadZShLib
askNecessaryQuestions