diff --git a/sh/main.sh b/sh/main.sh index 8339831..470cf72 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -29,13 +29,6 @@ RWX_SELF_NAME="rwx" # currently running shell name RWX_SHELL="$(cat "/proc/${$}/comm")" -# command name used to run -# (stripped from hyphen interactive flag) -RWX_COMMAND_NAME="$(basename "${0}" | sed "s|^-||")" -case "${RWX_COMMAND_NAME}" in -"bash" | "dash" | "sh") unset RWX_COMMAND_NAME ;; -*) ;; -esac # system root directory of the project RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_SELF_NAME}" # user root directory of the project @@ -62,9 +55,18 @@ rwx_main() { # load code cache rwx_code_load # context / command - if [ -n "${RWX_COMMAND_NAME}" ]; then + local command + # command name used to run + # (stripped from hyphen interactive flag) + command="$(basename "${0}" | sed "s|^-||")" + case "${command}" in + "bash" | "dash" | "sh") unset command ;; + *) ;; + esac + if [ -n "${command}" ]; then local function - function="$(rwx_code_alias_function "${RWX_COMMAND_NAME}")" + # find the matching function + function="$(rwx_code_alias_function "${command}")" if [ -n "${function}" ]; then "${function}" "${@}" fi