kiss: simplify pkg_find and ext use

This commit is contained in:
Dylan Araps 2021-07-03 10:15:06 +00:00
parent dee877e408
commit 60bdcdfe74
No known key found for this signature in database
GPG Key ID: 13295DAC2CF13B5C

19
kiss
View File

@ -157,12 +157,12 @@ pkg_lint() {
pkg_find() { pkg_find() {
# Figure out which repository a package belongs to by searching for # Figure out which repository a package belongs to by searching for
# directories matching the package name in $KISS_PATH/*. # directories matching the package name in $KISS_PATH/*.
query=$1 all=$2 what=$3 IFS=:; set -- query=$1 all=$2 what=$3 where=$4 IFS=:; set --
# Both counts of word-splitting are intentional here. Firstly to split # Both counts of word-splitting are intentional here. Firstly to split
# the repositories and secondly to allow for the query to be a glob. # the repositories and secondly to allow for the query to be a glob.
# shellcheck disable=2086 # shellcheck disable=2086
for path in $KISS_PATH "${what:-$sys_db}"; do set +f for path in ${where:-$KISS_PATH} "${what:-$sys_db}"; do set +f
for path2 in "$path/"$query; do for path2 in "$path/"$query; do
test "${what:--d}" "$path2" && set -f -- "$@" "$path2" test "${what:--d}" "$path2" && set -f -- "$@" "$path2"
done done
@ -1600,10 +1600,7 @@ args() {
# Behavior intentional. # Behavior intentional.
# shellcheck disable=2046,2030,2031 # shellcheck disable=2046,2030,2031
# see [1] at top of script. # see [1] at top of script.
set -- $( set -- $(pkg_find kiss-\* all -x "$PATH")
export KISS_PATH=$PATH
pkg_find kiss-\* all -x
)
# To align descriptions figure out which extension has the longest # To align descriptions figure out which extension has the longest
# name by doing a simple 'name > max ? name : max' on the basename # name by doing a simple 'name > max ? name : max' on the basename
@ -1627,14 +1624,8 @@ args() {
;; ;;
*) *)
# Behavior intentional. pkg_find "kiss-$action*" "" -x "$PATH"
# shellcheck disable=2030,2031 "$repo_dir" "$@"
util=$(
export KISS_PATH=$PATH
pkg_find "kiss-$action*" "" -x 2>/dev/null
) || die "'kiss $action' is not a valid command"
"$util" "$@"
;; ;;
esac esac