main/command
This commit is contained in:
parent
a7b310b667
commit
2480e490be
1 changed files with 11 additions and 9 deletions
20
sh/main.sh
20
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue