aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordylan.araps@gmail.com <dylan.araps@gmail.com>2020-01-28 21:32:38 +0000
committerdylan.araps@gmail.com <dylan.araps@gmail.com>2020-01-28 21:32:38 +0000
commit1077fce13388d4672a44a8fa4a000960cf6fb619 (patch)
tree40289499df29cb2431541cb3e156877a82c3077a
parent8bf2a805b2f8494485d8edc7bbcde345cbbd26c5 (diff)
downloadcpt-1077fce13388d4672a44a8fa4a000960cf6fb619.tar.gz
kiss: Support POSIX find in pkg_find
FossilOrigin-Name: bb7f269ee487e4583fb4b3289253229033bd38928a4669b1fea103779a6e3656
-rwxr-xr-xkiss10
1 files changed, 8 insertions, 2 deletions
diff --git a/kiss b/kiss
index c5ec626..cbc0557 100755
--- a/kiss
+++ b/kiss
@@ -182,13 +182,19 @@ pkg_find() {
query=$1
match=$2
+ # This ugly mess appends '/.' to the end of each path in
+ # '$KISS_PATH' as POSIX 'find' has no '-mindepth'/'-maxdepth'.
+ # See: https://unix.stackexchange.com/a/330372
+ IFS=:; set --
+ for path in $KISS_PATH; do set "$@" "$path/."; done
+ IFS=$old_ifs
+
# Find the repository containing a package.
# Searches installed packages if the package is absent
# from the repositories.
# See [1] at top of script.
# shellcheck disable=2046,2086
- set -- $(IFS=:
- find $KISS_PATH "$sys_db" -mindepth 1 -maxdepth 1 -name "$1")
+ set -- $(find "$@" "$sys_db/." \( ! -name . -prune \) -name "$query")
# A package may also not be found due to a repository not being
# readable by the current user. Either way, we need to die here.