cpt

[ARCHIVED] Carbs Packaging Tools
git clone git://git.ckyln.com/~cem/cpt.git
Log | Files | Refs | README | LICENSE

commit d1b627e02cb4a9ca688b3fe5244bb184e8d82f2e
parent 9df0674486ac2dfd15f56aca0eb8011fcf98106b
Author: Cem Keylan <cem@ckyln.com>
Date:   Fri,  3 Apr 2020 19:36:41 +0300

kiss: use for-loop instead of find

Diffstat:
Mkiss | 29++++++++++++-----------------
1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/kiss b/kiss @@ -118,24 +118,19 @@ pkg_find() { # Figure out which repository a package belongs to by # searching for directories matching the package name # in $KISS_PATH/*. - query=$1 match=$2 + query=$1 match=$2 IFS=:; set -- - # 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 + # Word splitting is intentional here. + # shellcheck disable=2086 + for path in $KISS_PATH "$sys_db" ; do + set +f - # Find the repository containing a package. - # Searches installed packages if the package is absent - # from the repositories. This ugly mess is thanks to POSIX - # find which has no '-mindepth'/'-maxdepth', etc. - # See: https://unix.stackexchange.com/a/330372 - # See [1] at top of script. - # shellcheck disable=2046,2086 - set -- $(find "$@" "$sys_db/." \( ! -name . -prune \) \ - ! -name .git -a -name "$query" \( -type d -o -type l \)) + for path2 in "$path/"$query; do + [ -d "$path2" ] && set -f -- "$@" "$path2" + done + done + + IFS=$old_ifs # 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. @@ -1311,7 +1306,7 @@ args() { l|list) pkg_list "$@" ;; u|update) pkg_updates ;; s|search) for pkg do pkg_find "$pkg" all; done ;; - v|version) log kiss 1.11.0-carbs ;; + v|version) log kiss 1.11.1-carbs ;; h|help|-h|--help|'') log 'kiss [a|b|c|f|i|l|r|s|u|v] [pkg] [pkg] [pkg]'