# ╭──────╮ # │ self │ # ╰──────╯ # ╭──────┬────────╮ # │ self │ subset │ # ╰──────┴────────╯ # TODO move to code module rwx_self_subset() { local argument file root for argument in "${@}"; do root="${rwx_main_root}/${argument}" file="${argument}.${RWX_MAIN_EXTENSION}" if [ -d "${root}" ]; then local file for file in $(rwx_main_find "${root}"); do echo "${argument}/${file}.${RWX_MAIN_EXTENSION}" done elif [ -f "${rwx_main_root}/${file}" ]; then echo "${file}" fi done } # ╭──────┬───────╮ # │ self │ write │ # ╰──────┴───────╯ # TODO move to code module rwx_self_write() { local target="${1}" if [ -n "${target}" ]; then shift local file files text text="#! /usr/bin/env sh " files="$(rwx_self_subset "${@}")" while IFS= read -r file; do text="${text} $(cat "${rwx_main_root}/${file}") " done <