#! /usr/bin/env sh # ╭──────╮ # │ main │ # ╰──────╯ # ╭──────┬───────────╮ # │ main │ constants │ # ╰──────┴───────────╯ # parent directory for the project RWX_MAIN_PARENT="/usr/local/lib" # name of the project itself RWX_MAIN_NAME="rwx" # name of the entrypoint module RWX_MAIN_MODULE="main" # extension of shell modules RWX_MAIN_EXTENSION="sh" # ╭──────┬───────────╮ # │ main │ variables │ # ╰──────┴───────────╯ # system root directory of the project rwx_main_root="${RWX_MAIN_PARENT}/${RWX_MAIN_NAME}" # ╭──────┬──────╮ # │ main │ find │ # ╰──────┴──────╯ # find directory’s shell files #| find #| sed #| sort rwx_main_find() { local root="${1}" find \ "${root}" \ -name "*.${RWX_MAIN_EXTENSION}" \ -type "f" \ -printf "%P\n" | sed "s|\\.[^.]*\$||" | sort } # ╭──────┬──────╮ # │ main │ main │ # ╰──────┴──────╯ # run initial steps #< core/code rwx_main_main() { local module modules # find & source modules modules="$(rwx_main_find "${rwx_main_root}")" while IFS= read -r module; do if [ "${module}" != "${RWX_MAIN_MODULE}" ]; then # shellcheck disable=SC1090 . "${rwx_main_root}/${module}.${RWX_MAIN_EXTENSION}" fi done <