self/subset,write

This commit is contained in:
Marc Beninca 2024-12-02 00:06:42 +01:00
parent ce872d4ecb
commit 7dbf581191
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

View file

@ -45,3 +45,34 @@ rwx_self_install() {
rwx_remove "${file}"
rwx_link "${file}" "${RWX_MAIN_PATH}"
}
rwx_self_subset() {
local argument path
for argument in "${@}"; do
path="${RWX_ROOT_SYSTEM}/${argument}"
if [ -d "${path}" ]; then
rwx_find_shell "${path}"
elif [ -f "${path}" ]; then
echo "${argument}"
fi
done
}
rwx_self_write() {
local target="${1}"
if [ -n "${target}" ]; then
shift
local file text
text="#! /usr/bin/env sh
"
rwx_ifs_set
for file in $(rwx_self_subset "${@}"); do
text="${text}
# ${file}
$(cat "${RWX_ROOT_SYSTEM}/${file}")"
done
rwx_ifs_unset
rwx_file_write "${target}" "${text}"
fi
}