From c3fa50a92166cf60be4864527a73dc1c5566b7f1 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 6 Jul 2021 20:41:25 +0300 Subject: [PATCH] unify argument parsing --- kiss | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/kiss b/kiss index 5e19263..6e8bea7 100755 --- a/kiss +++ b/kiss @@ -1516,25 +1516,23 @@ args() { esac ;; - b|build|c|checksum|d|download|l|list|r|remove) - case $* in */*|*\**|*\!*|*\[*|*\]*) - die "Arguments contain invalid characters: '/!*[]' ($*)" + b|build|c|checksum|d|download|i|install|l|list|r|remove) + case ${action%%"${action#?}"}-$* in + i-*[\*\!\[\]]*) + die "Arguments contain invalid characters: '!*[]' ($*)" + ;; + + [!i]-*[\*\!\[\]/]*) + die "Arguments contain invalid characters: '!*[]/' ($*)" + ;; + + [!l]-) + # Use basename of current directory as package. + export KISS_PATH=${PWD%/*}:$KISS_PATH + set -- "${PWD##*/}" + ;; esac ;; - - i|install) - case $* in *\**|*\!*|*\[*|*\]*) - die "Arguments contain invalid characters: '!*[]' ($*)" - esac - ;; - esac - - # CRUX style usage using the current directory as the name of the package - # to be operated on. This needs to sit before the 'as_root()' calls as - # they reset the current working directory during their invocations. - [ "$1" ] || case $action in b|build|c|checksum|d|download|i|install|r|remove) - export KISS_PATH=${PWD%/*}:$KISS_PATH - set -- "${PWD##*/}" esac # Rerun the script as root with a fixed environment if needed. We sadly