From a4a155a472cb49c279826f04c9414cc31277d827 Mon Sep 17 00:00:00 2001 From: merakor Date: Sat, 18 Apr 2020 21:43:26 +0000 Subject: kiss: split search into singlesearch and search Outputting only a single directory on subshells disregard alternative use-cases where the user might actually want the full output. There might be alternative use-cases where the user might want single output without the use of a subshell. This change is to be sane while keeping up with most use-cases. FossilOrigin-Name: 702838f48d6ceb4091a2c79c52c7089b36212b1c95d0dff954c7e4dc4bf5e3e2 --- kiss | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/kiss b/kiss index 7c0744f..abe242a 100755 --- a/kiss +++ b/kiss @@ -120,7 +120,7 @@ pkg_find() { # Figure out which repository a package belongs to by # searching for directories matching the package name # in $KISS_PATH/*. - query=$1 IFS=:; set -- + query=$1 match=$2 IFS=:; set -- # Word splitting is intentional here. # shellcheck disable=2086 @@ -140,7 +140,7 @@ pkg_find() { # Show all search results if called from 'kiss search', else # print only the first match. - [ -t 1 ] && printf '%s\n' "$@" || printf '%s\n' "$1" + [ "$match" ] && printf '%s\n' "$@" || printf '%s\n' "$1" } pkg_list() { @@ -1330,10 +1330,11 @@ args() { done ;; - b|build) pkg_build "${@:?No packages installed}" ;; - l|list) pkg_list "$@" ;; - u|update) pkg_updates ;; - s|search) for pkg do pkg_find "$pkg"; done ;; + b|build) pkg_build "${@:?No packages installed}" ;; + l|list) pkg_list "$@" ;; + u|update) pkg_updates ;; + s|search) for pkg do pkg_find "$pkg" all; done ;; + ss|singlesearch) for pkg do pkg_find "$pkg"; done ;; v|version) log kiss 1.12.3 ;; h|help|-h|--help|'') @@ -1346,6 +1347,7 @@ args() { log 'list: List installed packages' log 'remove: Remove a package' log 'search: Search for a package' + log 'singlesearch: Output the first match of a package' log 'update: Check for updates' log 'version: Package manager version' ;; -- cgit v1.2.3