From 45d787d3cb4af0a9b3bd85f17a17215fea8d62c3 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Thu, 3 Apr 2025 00:26:54 +0200 Subject: [PATCH] Fix. --- testing/home/desktop/.local/bin/borgplom | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/testing/home/desktop/.local/bin/borgplom b/testing/home/desktop/.local/bin/borgplom index 4cc1578..927bbba 100755 --- a/testing/home/desktop/.local/bin/borgplom +++ b/testing/home/desktop/.local/bin/borgplom @@ -16,13 +16,23 @@ _print_usage() { echo "Usage: ${BIN_NAME} COMMAND" echo "Wrapper around certain borgbackup usages.\n" echo "Available commands:\n" + _MAX_LEN_INDEX=0 for _CMD in ${COMMANDS}; do _INDEX=" ${_CMD}$(eval printf '"%s"' '"${HELP_ARGS_'${_CMD}'}"')" - printf '%s' "${_INDEX}" - if [ $(printf '%s' "${_INDEX}" | wc -c) -lt 12 ]; then - printf '\t' + _LEN_INDEX=$(echo -n "${_INDEX}" | wc -c) + if [ "${_LEN_INDEX}" -gt "${_MAX_LEN_INDX}" ]; then + _MAX_LEN_INDEX="${_LEN_INDEX}" fi - eval printf '"\t%s\n"' '"${HELP_DESC_'${_CMD}'}"' + done + for _CMD in ${COMMANDS}; do + _INDEX=" ${_CMD}$(eval printf '"%s"' '"${HELP_ARGS_'${_CMD}'}"')" + _LEN_INDEX=$(echo -n "${_INDEX}" | wc -c) + printf '%s' "${_INDEX}" + _LEN_GAP=$(calc "${_MAX_LEN_INDEX} - ${_LEN_INDEX} + 2") + for _ in seq 1 ${_LEN_GAP}; do + printf ' ' + done + eval printf '"%s\n"' '"${HELP_DESC_'${_CMD}'}"' done } -- 2.30.2