From a1425647703d9c2080962876018cb257dcfc8a26 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Wed, 2 Apr 2025 22:48:58 +0200 Subject: [PATCH] Fix. --- testing/home/desktop/.local/bin/borgplom | 27 +++++++++++------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/testing/home/desktop/.local/bin/borgplom b/testing/home/desktop/.local/bin/borgplom index 846a3fe..a52fcfe 100755 --- a/testing/home/desktop/.local/bin/borgplom +++ b/testing/home/desktop/.local/bin/borgplom @@ -53,7 +53,7 @@ _check_args_beyond() { fi } -cmd_claim() { +CMD__claim() { _check_args_beyond 1 "$@" _PATH_SOURCE="$1" _ensure_no_overwrite_at() { @@ -83,12 +83,12 @@ cmd_claim() { chmod u+rw "${_PATH_TARGET_KEY}" "${_PATH_TARGET_LOCATION}" } -cmd_help() { +CMD__help() { _check_args_beyond 0 "$@" _print_usage } -cmd_keys() { +CMD__keys() { _check_args_beyond 0 "$@" _exit_ok() { echo "(none, since directory ${1})" @@ -115,7 +115,7 @@ cmd_keys() { done } -cmd_orgpull() { +CMD__orgpull() { _check_args_beyond 0 "$@" _NAME_ARCHIVE=orgdir @@ -170,16 +170,13 @@ cmd_orgpull() { if [ "$#" -lt 1 ]; then error_exit_with_usage "missing command." fi -CMD="$1" -shift 1 -if [ "${CMD}" = "${CMD_CLAIM}" ]; then - cmd_claim $@ -elif [ "${CMD}" = "${CMD_HELP}" ]; then - cmd_help $@ -elif [ "${CMD}" = "${CMD_KEYS}" ]; then - cmd_keys $@ -elif [ "${CMD}" = "${CMD_ORGPULL}" ]; then - cmd_orgpull $@ -else +CMD_FUNC="CMD__$1" +set +e +type "${CMD_FUNC}" > /dev/null 2>&1 +RESULT="$?" +set -e +if [ ! "${RESULT}" = 0 ]; then error_exit_with_usage "unknown command: ${1}" fi +shift 1 +"${CMD_FUNC}" $@ -- 2.30.2