kiss: Support CRUX-like usage

This commit is contained in:
Dylan Araps 2020-04-15 08:39:03 +00:00
parent f11b6e39b6
commit acb9398f62
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E
1 changed files with 7 additions and 6 deletions

13
kiss
View File

@ -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}"
;;