diff options
author | P. J. McDermott <pjm@nac.net> | 2013-07-16 17:32:58 (EDT) |
---|---|---|
committer | P. J. McDermott <pjm@nac.net> | 2013-07-16 17:32:58 (EDT) |
commit | 66ae93b8447d6bfe12b7dff86954b9f8ac28f6bd (patch) | |
tree | 47b9c22a82cca6c17f4851312861567d48a1e6be /lib | |
parent | 98d036c32b28df9ca4bb75a58d4156f15712db4d (diff) |
print_cmd_{summaries,usage}(): Clean cmd names.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cmd.sh | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -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}" } |