home · contact · privacy
Fix.
authorChristian Heller <c.heller@plomlompom.de>
Wed, 2 Apr 2025 20:48:58 +0000 (22:48 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 2 Apr 2025 20:48:58 +0000 (22:48 +0200)
testing/home/desktop/.local/bin/borgplom

index 846a3fe18fbd68bd471e3dd3e92b3090bf0b31a1..a52fcfec8673888ecd476831325d7c715ec13965 100755 (executable)
@@ -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}" $@