From 759e4fb868de2553ac4382bd89cabfb7ad682af5 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 14 Jul 2021 10:04:18 +0300 Subject: [PATCH] pkg_find: use case --- kiss | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/kiss b/kiss index 2da238d..87c7097 100755 --- a/kiss +++ b/kiss @@ -210,13 +210,24 @@ pkg_find() { unset 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. - [ "$5" ] || return 1 - # Show all search results if called from 'kiss search', else store the - # value in a variable. - [ "$2" ] && { shift 4; printf '%s\n' "$@"; } || repo_dir=$5 + # values in variables. + case $2-$# in + *-4) + # 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. + return 1 + ;; + + -*) + repo_dir=$5 + ;; + + *) + shift 4 + printf '%s\n' "$@"; + ;; + esac } pkg_list() {