diff options
author | merakor <cem@ckyln.com> | 2020-04-18 21:43:26 +0000 |
---|---|---|
committer | merakor <cem@ckyln.com> | 2020-04-18 21:43:26 +0000 |
commit | a4a155a472cb49c279826f04c9414cc31277d827 (patch) | |
tree | 8b24d3766d6fdef8ba6f9f71d901fb899a43fe27 | |
parent | 1e74e3470ba975fb280d3f0d27fcf914c43c5e8d (diff) | |
download | cpt-a4a155a472cb49c279826f04c9414cc31277d827.tar.gz |
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
-rwxr-xr-x | kiss | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -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' ;; |