find with extension

This commit is contained in:
Marc Beninca 2025-07-27 13:00:04 +02:00
parent 9e3c268b1c
commit 52593c9571
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F
4 changed files with 5 additions and 7 deletions

View file

@ -289,10 +289,10 @@ rwx_code_main() {
# find user modules # find user modules
rwx_code_modules_user="$(rwx_main_find "${rwx_code_root}")" rwx_code_modules_user="$(rwx_main_find "${rwx_code_root}")"
# source user modules # source user modules
[ "${rwx_code_modules_user}" ] && [ -n "${rwx_code_modules_user}" ] &&
while IFS= read -r module; do while IFS= read -r module; do
# shellcheck disable=SC1090 # shellcheck disable=SC1090
. "${rwx_code_root}/${module}.${RWX_MAIN_EXTENSION}" . "${rwx_code_root}/${module}"
done <<EOF done <<EOF
${rwx_code_modules_user} ${rwx_code_modules_user}
EOF EOF

View file

@ -4,7 +4,7 @@ rwx_shellcheck() {
file="$(mktemp)" file="$(mktemp)"
modules="$(rwx_main_find "${root}")" modules="$(rwx_main_find "${root}")"
while IFS= read -r module; do while IFS= read -r module; do
path="${root}/${module}.${RWX_MAIN_EXTENSION}" path="${root}/${module}"
echo ". \"${path}\"" >>"${file}" echo ". \"${path}\"" >>"${file}"
done <<EOF done <<EOF
${modules} ${modules}

View file

@ -35,7 +35,6 @@ rwx_main_path="${rwx_main_root}/${rwx_main_file}"
# FIXME separate in two functions # FIXME separate in two functions
# find root directory shell modules # find root directory shell modules
#| find #| find
#| sed
#| sort #| sort
rwx_main_find() { rwx_main_find() {
local root="${1}" local root="${1}"
@ -45,7 +44,6 @@ rwx_main_find() {
-name "*.${RWX_MAIN_EXTENSION}" \ -name "*.${RWX_MAIN_EXTENSION}" \
-type "f" \ -type "f" \
-printf "%P\n" | -printf "%P\n" |
sed "s|\\.[^.]*\$||" |
sort sort
} }
@ -66,7 +64,7 @@ rwx_main_main() {
# except currently running main module # except currently running main module
if [ "${module}" != "${RWX_MAIN_MODULE}" ]; then if [ "${module}" != "${RWX_MAIN_MODULE}" ]; then
# shellcheck disable=SC1090 # shellcheck disable=SC1090
. "${rwx_main_root}/${module}.${RWX_MAIN_EXTENSION}" . "${rwx_main_root}/${module}"
fi fi
done <<EOF done <<EOF
${modules} ${modules}

View file

@ -15,7 +15,7 @@ rwx_self_subset() {
if [ -d "${root}" ]; then if [ -d "${root}" ]; then
local file local file
for file in $(rwx_main_find "${root}"); do for file in $(rwx_main_find "${root}"); do
echo "${argument}/${file}.${RWX_MAIN_EXTENSION}" echo "${argument}/${file}"
done done
elif [ -f "${rwx_main_root}/${file}" ]; then elif [ -f "${rwx_main_root}/${file}" ]; then
echo "${file}" echo "${file}"