aboutsummaryrefslogtreecommitdiff
path: root/kiss
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2020-05-11 12:13:18 +0000
committermerakor <cem@ckyln.com>2020-05-11 12:13:18 +0000
commit5ceab56b85cda2619492e2246c177e1ae8c7d9e8 (patch)
treeda1780fbd02fe53c8e8eb39ab0f53821d679cf30 /kiss
parenta304471254521196cefe8bfc3e6a3b784a38337a (diff)
downloadcpt-5ceab56b85cda2619492e2246c177e1ae8c7d9e8.tar.gz
kiss: make sure directories and executables don't clash
kiss will no longer look for sys_db when called from extensions. An alternate 'SEARCH_PATH' is used now to store KISS_PATH and sys_db together. This SEARCH_PATH will be overriden by PATH if it is called from extensions. FossilOrigin-Name: 9af1b446d03b7008d158b56831f7a82fd1963a9297492adf8b87fe0c278addd0
Diffstat (limited to 'kiss')
-rwxr-xr-xkiss15
1 files changed, 10 insertions, 5 deletions
diff --git a/kiss b/kiss
index 6b3ee01..bb35d10 100755
--- a/kiss
+++ b/kiss
@@ -131,18 +131,23 @@ pkg_lint() {
}
pkg_find() {
+ # Use a SEARCH_PATH variable so that we can get the sys_db into
+ # the same variable as KISS_PATH. This makes it easier when we are
+ # searching for executables instead of KISS_PATH.
+ : "${SEARCH_PATH:=$KISS_PATH:$sys_db}"
+
# Figure out which repository a package belongs to by
# searching for directories matching the package name
# in $KISS_PATH/*.
- query=$1 match=$2 IFS=:; set --
+ query=$1 match=$2 type=$3 IFS=:; set --
# Word splitting is intentional here.
# shellcheck disable=2086
- for path in $KISS_PATH "$sys_db" ; do
+ for path in $SEARCH_PATH ; do
set +f
for path2 in "$path/"$query; do
- [ -x "$path2" ] && set -f -- "$@" "$path2"
+ test "${type:--d}" "$path2" && set -f -- "$@" "$path2"
done
done
@@ -1455,7 +1460,7 @@ args() {
log "Installed extensions"
set --
- for path in $(KISS_PATH=$PATH pkg_find kiss-* all); do
+ for path in $(SEARCH_PATH=$PATH pkg_find kiss-* all -x); do
set -- "${path#*/kiss-}" "$@"
max=$((${#1} > max ? ${#1} : max))
done
@@ -1513,7 +1518,7 @@ args() {
;;
*)
- util=$(KISS_PATH=$PATH pkg_find "kiss-$action"* 2>/dev/null) ||
+ util=$(SEARCH_PATH=$PATH pkg_find "kiss-$action"* "" -x 2>/dev/null) ||
die "'kiss $action' is not a valid command"
"$util" "$@"