From 66ae93b8447d6bfe12b7dff86954b9f8ac28f6bd Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Tue, 16 Jul 2013 17:32:58 -0400 Subject: print_cmd_{summaries,usage}(): Clean cmd names. --- diff --git a/lib/cmd.sh b/lib/cmd.sh index 40bb992..efb8b8c 100644 --- a/lib/cmd.sh +++ b/lib/cmd.sh @@ -39,7 +39,7 @@ load_cmds() print_cmd_summaries() { - local padding cmd summary + local padding cmd cmd_clean summary padding="$(printf '%24s' '')" for cmd in ${PKGLIBCMD}; do @@ -50,7 +50,9 @@ print_cmd_summaries() else printf ' %-20s ' "${cmd}" fi - summary="$(get_msg "cmd_${cmd}_summary")" + cmd_clean="$(printf '%s' "${cmd}" | \ + tr '[A-Z]' '[a-z]' | tr -C '[a-z0-9_]' '_')" + summary="$(get_msg "cmd_${cmd_clean}_summary")" printf '%s\n' "${summary}" | fold -s -w 56 | \ sed "2,\$s/^/${padding}/;" done @@ -58,11 +60,13 @@ print_cmd_summaries() print_cmd_usage() { - local cmd usage + local cmd cmd_clean usage cmd="${1}" - usage="$(get_msg "cmd_${cmd}_usage")" + cmd_clean="$(printf '%s' "${cmd}" | \ + tr '[A-Z]' '[a-z]' | tr -C '[a-z0-9_]' '_')" + usage="$(get_msg "cmd_${cmd_clean}_usage")" printf "$(get_msg 'cmd_usage')\n" "${0}" "${cmd}" "${usage}" } -- cgit v0.9.1