From acb9398f62325aeb7c4b73c8130a3af30c6a218c Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 15 Apr 2020 08:39:03 +0000 Subject: [PATCH] kiss: Support CRUX-like usage --- kiss | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/kiss b/kiss index 6039b35..7d46f5d 100755 --- a/kiss +++ b/kiss @@ -1170,7 +1170,7 @@ args() { # Parse some arguments earlier to remove the need to duplicate code. case $action in - c|checksum|s|search) + s|search) [ "$1" ] || die "'kiss $action' requires an argument" ;; @@ -1184,8 +1184,6 @@ args() { ;; i|install|r|remove) - [ "$1" ] || die "'kiss $action' requires an argument" - # Rerun the script with 'su' if the user isn't root. # Cheeky but 'su' can't be used on shell functions themselves. [ "$uid" = 0 ] || { @@ -1195,6 +1193,12 @@ args() { ;; esac + # Second early check to use $PWD in place of arguments. + case $action in b|build|c|checksum|i|install|r|remove) + export KISS_PATH=${PWD%/*}:$KISS_PATH + set -- "${PWD##*/}" + esac + # Actions can be abbreviated to their first letter. This saves # keystrokes once you memorize the commands. case $action in @@ -1217,9 +1221,6 @@ args() { ;; b|build) - # If no arguments were passed, rebuild all packages. - [ "$1" ] || { cd "$sys_db" && { set +f; set -f -- *; } } - pkg_build "${@:?No packages installed}" ;;