diff --git a/sh/core/code.sh b/sh/core/code.sh index af9962f..3d65f5c 100644 --- a/sh/core/code.sh +++ b/sh/core/code.sh @@ -6,15 +6,16 @@ # │ code │ variables │ # ╰──────┴───────────╯ +# TODO variablize # path to the entrypoint main file of the project -rwx_code_main="${rwx_main_root}/${RWX_MAIN_MODULE}.${RWX_MAIN_EXTENSION}" +RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}.${RWX_MAIN_EXTENSION}" # user root directory of the project -rwx_code_root="${HOME}/${RWX_MAIN_NAME}" +RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}" # cache of all sourced code modules _rwx_code="" # cache for the parsing awk script -_rwx_code_awk="$(cat "${rwx_main_root}/core/code.awk")" +_rwx_code_awk="$(cat "${RWX_ROOT_SYSTEM}/core/code.awk")" # cache for code aliases _rwx_code_aliases="" # cache for code aliases functions @@ -54,16 +55,16 @@ rwx_code_install() { local command file name root # code if [ -n "${target}" ]; then - root="${target}${rwx_main_root}" + root="${target}${RWX_ROOT_SYSTEM}" rwx_remove "${root}" - cp --recursive "${rwx_main_root}" "${root}" + cp --recursive "${RWX_ROOT_SYSTEM}" "${root}" fi # commands root="${target}/usr/local/bin" - name="${RWX_MAIN_NAME}.${RWX_MAIN_EXTENSION}" + name="${RWX_SELF_NAME}.${RWX_MAIN_EXTENSION}" file="${root}/${name}" rwx_remove "${file}" - rwx_link "${file}" "${rwx_code_main}" + rwx_link "${file}" "${RWX_MAIN_PATH}" while IFS= read -r command; do file="${root}/${command}" rwx_remove "${file}" @@ -72,15 +73,15 @@ rwx_code_install() { ${_rwx_code_commands} EOF # sh - file="${target}/etc/profile.d/${RWX_MAIN_NAME}.${RWX_MAIN_EXTENSION}" + file="${target}/etc/profile.d/${RWX_SELF_NAME}.${RWX_MAIN_EXTENSION}" rwx_remove "${file}" rwx_file_write "${file}" "\ -export ENV=\"${rwx_code_main}\" +export ENV=\"${RWX_MAIN_PATH}\" " # bash file="${target}/etc/bash.bashrc" rwx_remove "${file}" - rwx_link "${file}" "${rwx_code_main}" + rwx_link "${file}" "${RWX_MAIN_PATH}" } # ╭──────┬───────╮ @@ -163,10 +164,10 @@ rwx_code_variables() { rwx_code_check() { # check format rwx_log - rwx_shfmt "${rwx_main_root}" + rwx_shfmt "${RWX_ROOT_SYSTEM}" # check syntax rwx_log - rwx_shellcheck "${rwx_main_root}" + rwx_shellcheck "${RWX_ROOT_SYSTEM}" } # fetch matching doc for given name @@ -227,10 +228,10 @@ rwx_code_main() { local modules_main="${1}" local module modules_user # find & source modules - modules_user="$(rwx_main_find "${rwx_code_root}")" + modules_user="$(rwx_main_find "${RWX_SELF_USER}")" while IFS= read -r module; do # shellcheck disable=SC1090 - . "${rwx_code_root}/${module}.${RWX_MAIN_EXTENSION}" + . "${RWX_SELF_USER}/${module}.${RWX_MAIN_EXTENSION}" done <