From a485cb133ef7d64473a7d7345edec8ac4d7a6af0 Mon Sep 17 00:00:00 2001 From: Rico Tiongson Date: Tue, 21 Apr 2020 04:43:42 +0800 Subject: [PATCH] Add abort statuement --- comfortable-swipe | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/comfortable-swipe b/comfortable-swipe index 94d2136..28d6e4a 100755 --- a/comfortable-swipe +++ b/comfortable-swipe @@ -395,24 +395,19 @@ elif declare -f "$1" >/dev/null 2>&1; then # TODO: unset all nonlocal functions "$@" # same as "$1" "$2" "$3" ... for full argument list else - # try to invoke config set / get depending on number of arguments - if [[ $# -eq 1 ]]; then - # one argument, use shorthand get - "$BASENAME" config get "$1" 2> /dev/null - retval=$? - else - # multiple arguments, use shorthand set - config set "$@" 2> /dev/null - retval=$? - fi - if $retval; then - exit $retval - else + function abort { echo "Error: $1 not recognized" >&2 echo >&2 usage >&2 echo -n "Valid props: " >&2 echo "$KEYS" | sed 's/|/, /g' >&2 + } + # try to invoke config set / get depending on number of arguments + if [[ $# -eq 1 ]]; then + # one argument, use shorthand get + "$BASENAME" config get "$1" || abort + else + # multiple arguments, use shorthand set + config set "$@" 2> /dev/null || abort fi - exit $retval fi