From 5ceab56b85cda2619492e2246c177e1ae8c7d9e8 Mon Sep 17 00:00:00 2001 From: merakor Date: Mon, 11 May 2020 12:13:18 +0000 Subject: 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 --- kiss | 15 ++++++++++----- 1 file 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" "$@" -- cgit v1.2.3