This commit is contained in:
Marc Beninca 2024-11-29 15:42:58 +01:00
parent 321070d5cc
commit b93a6909bb
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

View file

@ -37,6 +37,7 @@ _sh_main_log() {
# public
# find directory’s files by extension
sh_find_extension() {
local extension="${1}"
local root="${2}"
@ -54,16 +55,19 @@ sh_find_extension() {
sort
}
# find directory’s sh files
sh_find_sh() {
sh_find_extension "sh" "${@}"
}
# get functions from file
sh_grep_functions() {
local file="${1}"
grep "()" "${file}" |
cut --delimiter "(" --fields 1
}
# output help message
sh_help() {
sh_log \
"sh_… = shell functions" \
@ -71,6 +75,7 @@ sh_help() {
"u__… = user"
}
# test if active shell is in interactive mode
sh_shell_interactive() {
case "${-}" in
*i*) ;;
@ -106,18 +111,25 @@ sh_source_directory() {
# main
# run initial steps
sh_main() {
# system root
if ! sh_source_directory "${SH_ROOT}"; then
_sh_main_log "Not a directory: ${SH_ROOT}"
return 1
fi
# user root
sh_source_directory "${SH_USER}"
# run interactive extras
if sh_shell_interactive; then
# check
sh_log
sh_shellcheck "${SH_ROOT}"
# help
sh_log
sh_help
fi
}
# run main function
sh_main