main/find
This commit is contained in:
parent
048f41cd05
commit
222972b6df
3 changed files with 8 additions and 14 deletions
|
@ -2,7 +2,7 @@ rwx_shellcheck() {
|
||||||
local root="${1}"
|
local root="${1}"
|
||||||
local file module modules path
|
local file module modules path
|
||||||
file="$(mktemp)"
|
file="$(mktemp)"
|
||||||
modules="$(rwx_find_shell "${root}")"
|
modules="$(rwx_main_find "${root}")"
|
||||||
while IFS= read -r module; do
|
while IFS= read -r module; do
|
||||||
path="${root}/${module}"
|
path="${root}/${module}"
|
||||||
echo ". \"${path}\"" >>"${file}"
|
echo ". \"${path}\"" >>"${file}"
|
||||||
|
|
18
sh/main.sh
18
sh/main.sh
|
@ -28,16 +28,15 @@ RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_SELF_NAME}"
|
||||||
# │ main │ find │
|
# │ main │ find │
|
||||||
# ╰──────┴──────╯
|
# ╰──────┴──────╯
|
||||||
|
|
||||||
# find directory’s files by extension
|
# find directory’s shell files
|
||||||
#| find
|
#| find
|
||||||
#| sort
|
#| sort
|
||||||
rwx_find_extension() {
|
rwx_main_find() {
|
||||||
local extension="${1}"
|
local root="${1}"
|
||||||
local root="${2}"
|
local file="${2}"
|
||||||
local file="${3}"
|
|
||||||
set -- \
|
set -- \
|
||||||
"${root}" \
|
"${root}" \
|
||||||
-name "*.${extension}" \
|
-name "*.sh" \
|
||||||
-type "f"
|
-type "f"
|
||||||
[ -n "${file}" ] &&
|
[ -n "${file}" ] &&
|
||||||
set -- "${@}" \
|
set -- "${@}" \
|
||||||
|
@ -48,11 +47,6 @@ rwx_find_extension() {
|
||||||
sort
|
sort
|
||||||
}
|
}
|
||||||
|
|
||||||
# find directory’s sh files
|
|
||||||
rwx_find_shell() {
|
|
||||||
rwx_find_extension "sh" "${@}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ╭──────┬───────╮
|
# ╭──────┬───────╮
|
||||||
# │ main │ shell │
|
# │ main │ shell │
|
||||||
# ╰──────┴───────╯
|
# ╰──────┴───────╯
|
||||||
|
@ -93,7 +87,7 @@ rwx_main_source() {
|
||||||
count=0
|
count=0
|
||||||
_rwx_main_log "" \
|
_rwx_main_log "" \
|
||||||
". ${root}"
|
". ${root}"
|
||||||
modules="$(rwx_find_shell "${root}" "${file}")"
|
modules="$(rwx_main_find "${root}" "${file}")"
|
||||||
while IFS= read -r module; do
|
while IFS= read -r module; do
|
||||||
count=$((count + 1))
|
count=$((count + 1))
|
||||||
_rwx_main_log "$(printf "%02d" "${count}") ${module%.sh}"
|
_rwx_main_log "$(printf "%02d" "${count}") ${module%.sh}"
|
||||||
|
|
|
@ -14,7 +14,7 @@ rwx_self_subset() {
|
||||||
file="${argument}.sh"
|
file="${argument}.sh"
|
||||||
if [ -d "${root}" ]; then
|
if [ -d "${root}" ]; then
|
||||||
local file
|
local file
|
||||||
for file in $(rwx_find_shell "${root}"); do
|
for file in $(rwx_main_find "${root}"); do
|
||||||
echo "${argument}/${file}"
|
echo "${argument}/${file}"
|
||||||
done
|
done
|
||||||
elif [ -f "${RWX_ROOT_SYSTEM}/${file}" ]; then
|
elif [ -f "${RWX_ROOT_SYSTEM}/${file}" ]; then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue