main/command

This commit is contained in:
Marc Beninca 2025-07-07 05:33:43 +02:00
parent a7b310b667
commit 2480e490be
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

View file

@ -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