summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2013-07-16 18:35:02 (EDT)
committer P. J. McDermott <pjm@nac.net>2013-07-16 18:35:02 (EDT)
commitbff4ebe5b32e2ceeaccdf9375e80ef62b413a7ee (patch)
tree37ffe18a13302ddbe50bb8caf1b328c64ea0e67f
parent4c4dee4825a9a5ecf912cf0bc098dbdd4da221a5 (diff)
run_cmd(): Clean command name.
-rw-r--r--lib/cmd.sh5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/cmd.sh b/lib/cmd.sh
index 0558971..fa9b1ad 100644
--- a/lib/cmd.sh
+++ b/lib/cmd.sh
@@ -84,10 +84,13 @@ is_cmd()
run_cmd()
{
local cmd="${1}"
+ local cmd_clean=
shift
+ cmd_clean="$(printf '%s' "${cmd}" | \
+ tr '[A-Z]' '[a-z]' | tr -C '[a-z0-9_]' '_')"
if is_cmd "${cmd}"; then
- "cmd_${cmd}_main" "${@}"
+ "cmd_${cmd_clean}_main" "${@}"
else
error 1 "$(get_msg 'cmd_not_found')" "${cmd}"
fi